Facts Flashcards

1
Q

Como se podrían mostrar el fact de fqdn y la ip

A
Con el playbook 
—-
- name: Display some basic facts 
   hosts: servera.lab.example.com
   tasks: 
    - name: Show some properties of {{ inventory_hostname }}
       debug: 
           msg: > 
               My FQDN is {{ ansible_facts[‘fdqn’] }} and my default  IP address is {{ ansible_facts[‘default_ipv4’][‘address’] }}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Como se instalan los facts playbook servidor remoto

A

  • name: install remote facts
    hosts: web servervars:
    remote_dir: /etc/ansible/
    facts_file: custom.facttasks:
    • name: create the remote directory
      file:
      state: directory
      recurse: yes
      path: “{{ remote_dir }}”
    • name: install the new facts
      copy:
      src: “{{ facts_file }}”
      dest: “{{ remote_dir }}”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Como se usan los facts instalados remotamente para instalar paquetes locales e iniciar servicios

A

—-

  • name: install Apache and starts the service
    hosts: webserver
    tasks:
    • name: install the required package
      yum:
      name: “{{ ansible_facts[‘ansible_local’][‘custom’][‘general’][‘package’] }}”
      state: latest
    • name: start the service
      service:
      name: “{{ ansible_facts[‘ansible_local’][‘custom’][‘general’][‘service’] }} “
      state:“{{ ansible_facts[‘ansible_local’][‘custom’][‘general’][‘state’] }} “
      Enabled:“{{ ansible_facts[‘ansible_local’][‘custom’][‘general’][‘enabled’] }} “
How well did you know this?
1
Not at all
2
3
4
5
Perfectly