Ansible Inventory update Kodekloud



Question: The Nautilus DevOps team has started testing their Ansible playbooks on different servers within the stack. They have placed some playbooks under /home/thor/playbook/ on jump host which they want to test. Some of these playbooks have already been tested on different servers, but now they want to test them on app server 2 in Stratos DC. However, they first need to create an inventory file so that Ansible can connect to the respective app. Below are some requirements:

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

b. Add App Server 2 in this inventory along with required variables that are needed to make it work.

c. The inventory hostname of host should be the server name as per wiki, for example stapp01 for app server 1 in Stratos DC.

d. At the end /home/thor/playbook/playbook.yml, playbook should be able to run.

Note: Validation will try to run playbook using command ansible-playbook -i inventory playbook.yml so please make sure playbook works this way, without passing any extra arguments.


On Jump_Host go to playbook folder

cd home/thor/playbook/

Then create an inventory file

vi inventory

Add the mentioned server name, ip, username ,and password 

stapp02 ansible_host= ansible_connection=ssh  ansible_user=steve [email protected]

Save it

Then run the ansible playbook command

ansible-playbook -i inventory playbook.yml

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment


Post a Comment