Saranya. S
3 min readDec 1, 2020

ARTH — Task 11 👨🏻‍💻

Task Description📄

🔰 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

*Idempotence: Denoting an element of a set which is unchanged.

#Sometimes you want a task to run only when a change is made on a machine. For example, you may want to restart a service if a task updates the configuration of that service, but not if the configuration is unchanged. Ansible uses handlers to address this use case.

#Handlers are tasks that only run when notified. Each handler should have a globally unique name.

  • So, to rectify this challenge in Ansible playbook we use handlers module

STEP:1::Download ANSIBLE

cmd: pip3 install ansible

STEP:2:To create inventory

STEP:2.1:create a file

cmd: vim <filename>.txt [eg.,vim ip.txt or vim /root/ip.txt]

STEP:2.2:write a file

<ip> ansible_user=<user name> ansible_ssh_pass=<password> ansible_connection=ssh

STEP:3:To create ansible configuration file

  1. create a directory = cmd: mkdir /etc/ansible
  2. create a file = cmd: vim /etc/ansible/ansible.cfg

3. write a file:

To check:

cmd: ansible all — list-hosts (shows ip of target nodes that are connected)

STEP:4:To connect the hosts

cmd: dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

then install sshpass,

cmd: yum install sshpass

To check: ansible all -m ping

STEP:5:NOW, create a playbook:

  1. create a directory: cmd: mkdir /<name> [eg., mkdir /ansible]
  2. cd /ws ->create a file : vim <file name>.yml [eg., vim task2.yml]
  3. create a config file with ext “.conf”

write a file in task2.yml:

write a file in lw.conf:

TO CHECK:

Now, play the playbook;

cmd: ansible-playbook <file name>

Running it again…

COMPLETED!!!

No responses yet