Training #2 Familiar with Inventories and Playbooks

Overview:

Use Ansible with multiple inventories and playbooks.


Practice items:

  • – On the Ansible controller node
    • – Create a inventory file that contained ungrouped, grouped and nested hosts. Then use command “ansible” and ansible-inventory” to view them. Familiar with way to call and list them.
    • – Familiar with multiple inventories. Create another inventory file that contained different group of hosts. View all of hosts in the created inventory files, which include hosts created previously.
    • – Create a playbook to do following tasks on target group:
      • + Prompt to perform PING test.
      • + Single package installation
      • + Multiple packages installation.
      • + User account creation: linda, laura, lori and bob
      • + Gather accounts’ info, eg. id <username>
      • + Display gathered information on accounts and some system fact like OS distribution.
    • – Create four playbooks: init, discovery, main and cleanup. The “init” playbook will initiate other playbooks.
      • + init playbook calls playbooks in play in orders: discovery -> main -> clean-up.
      • + discovery playbook contains host discovery.
      • + main playbook contains main play/configuration: create user and file.
      • + cleanup: remove the file.

Practice items with some samples: