exam 4

 

  • 01
  • 02
  • 03
  • 04

Create a playbook facts.yml under ~/playbooks directory on Ansible controller. In this playbook using blockinfile module create a file facts.txt under /root on node02 host and add below given block in it. You will need to enable facts gathering for this task.

This is Ansible managed node `<hostname-of-host> `
IP address of host is `<ip-address-of-host>`
Its OS family is `<os-family>`

After that make a copy of this file as index.html under /usr/share/nginx/html/




Create facts.yml playbook and add below given code

---
- hosts: node02
  gather_facts: yes
  tasks:
    - name: Create facts.txt
      blockinfile:
        path: /root/facts.txt
        create: yes
        block: |
          This is Ansible managed node {{ ansible_nodename }}
          IP address of host is {{ ansible_default_ipv4.address }}
          Its OS family is {{ ansible_os_family }}

    - name: Make index.html
      copy:
        src: /root/facts.txt
        remote_src: yes
        dest: /usr/share/nginx/html/index.html

Comments

Popular posts from this blog

exam 16

ansible 5

practical 3