ARTH — Task 11.3
11.3 Restarting HTTPD Service is not idempotence in nature and also consume more resources suggest a way to rectify this challenge in Ansible playbook
Step 1
CONFIGURING ANSIBLE IN CONTROL NODE
Download Ansible
cmd: pip3 install ansible
Step 2 Create Inventory
Create one inventory file and add ip of managed nodes
for that we need to create a file:-
write the file with respective ip and username and password
Step 3 Create ansible conf file and append the inventory file
- create one dir:- mkdir /etc/ansible
- create a conf file:- vim /etc/ansible/ansible.cfg
- add inventory to conf file
- To check :- ansible all — list-hosts
Step 4 To connect host:- dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
then install sshpass:- yum install sshpass
To check: ansible all -m ping
Initial Setup is completed
Now we have to write the playbook
- create a directory: cmd: mkdir /<name> [eg., mkdir /ws]
- cd /ws ->create a file : vim <file name>.yml [eg., vim web.yml]
write the play book
write a file in lw.conf:
Now, the playbook
ansible-playbook <file name>
try again
Task succesfully completed