Question: 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 2 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 2 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.
1. Go through the folder mentioned in the task and verified the playbook and files existing
thor@jump_host ~$ ls -l /home/thor/playbook/ total 8 -rw-r--r-- 1 thor thor 36 Sep 28 07:04 ansible.cfg -rw-r--r-- 1 thor thor 250 Sep 28 07:04 playbook.yml thor@jump_host ~$ thor@jump_host ~$ cat /home/thor/playbook/playbook.yml --- - hosts: all become: yes become_user: root tasks: - name: Install httpd package yum: name: httpd state: installed - name: Start service httpd service: name: httpd state: started thor@jump_host ~$ |
2. Create an inventory file and add the app server as per your task.
(Refer to your task and add app server in inventory )
thor@jump_host ~$ cd /home/thor/playbook/
thor@jump_host ~/playbook$ cat /home/thor/playbook/inventory stapp02 ansible_host=172.16.238.11 ansible_ssh_pass=Am3ric@ ansible_user=steve thor@jump_host ~$ |
3. Post file saved, run below command to execute the playbook
thor@jump_host ~/playbook$ ansible-playbook -i inventory playbook.yml PLAY [all] ************************************************************************************************************************************************************* TASK [Gathering Facts] ************************************************************************************************************************************************* ok: [stapp02] TASK [Install httpd package] ******************************************************************************************************************************************* changed: [stapp02] TASK [Start service httpd] ********************************************************************************************************************************************* changed: [stapp02] PLAY RECAP ************************************************************************************************************************************************************* stapp02 : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 thor@jump_host ~/playbook$ |
Happy Learning!!!!
0 Comments