Restarting HTTPD Service is not idempotence in nature and also consume more resources suggest a way to rectify this challenge in Ansible playbook

Ashish Mangal
2 min readMar 20, 2021

For solving this problem we use handlers in ansible.

Handlers:

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.

For solving the above problem we write a ansible playbook and use handlers-:

Now run the playbook using the command-:

ansible-playbook {filename}.yml

So now handler will only run when any change is made on config file which we have used in template module and notify keyword used with template module will notify to handler if any if change is made or not.

Thank you 😊😊

--

--

Ashish Mangal
0 Followers

My name is Ashish Mangal. Currently I am pursuing B.tech in Electronics and Communication. A Technology Enthusiast!!!