100-Days-Of-DevOps-Challenge-KodeKloud

Create Ansible Inventory for App Server Testing

The Nautilus DevOps team is testing Ansible playbooks on various servers within their stack. They’ve placed some playbooks under /home/thor/playbook/ directory on the jump host and now intend to test them on app server 1 in Stratos DC. However, an inventory file needs creation for Ansible to connect to the respective app. Here are the requirements:

a. Create an ini type Ansible inventory file /home/thor/playbook/inventory on jump host.

b. Include App Server 1 in this inventory along with necessary variables for proper functionality.

c. Ensure the inventory hostname corresponds to the server name as per the wiki, for example stapp01 for app server 1 in Stratos DC.

Note: Validation will execute the playbook using the command ansible-playbook -i inventory playbook.yml. Ensure the playbook functions properly without any extra arguments.

Steps

  1. Create an inventory file:
    • Move into directory and create the file
     cd playbook
     vi inventory
    
    • copy-paste contents into inventory file
     [app]
     stapp01
    
     [app:vars]
     ansible_user=tony
     ansible_ssh_password=Ir0nM@n
     ansible_ssh_common_args='-o StrictHostKeyChecking=no'
    
  2. Run the ansible playbook command:

     ansible-playbook -i inventory playbook.yml
    

Good to Know?

Ansible Inventory

Inventory Structure

Connection Variables

Best Practices