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 3 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 3 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.
# Use a text editor to create or edit the inventory file
vi /home/thor/playbook/inventory
Add the following content to the file:
# /home/thor/playbook/inventory
[app_servers]
stapp03 ansible_host=172.16.238.12 ansible_user=banner ansible_ssh_pass=BigGr33n
The provided playbook.yml
is used to install and start the httpd
service. Ensure that the playbook syntax and indentation are correct.
# /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
Run the playbook to ensure everything is working as expected:
ansible-playbook -i inventory playbook.yml
Make sure that after executing the playbook, the following output is produced:
PLAY [all] ******************************************************************************
TASK [Gathering Facts] ******************************************************************
ok: [stapp03]
TASK [Install httpd package] ************************************************************
changed: [stapp03]
TASK [Start service httpd] **************************************************************
changed: [stapp03]
PLAY RECAP ******************************************************************************
stapp03 : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0