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

Bhavna Surendra Latare
2 min readMar 21, 2021

Idempotent Ansible means the operation that can be applied multiple times without changing the result beyond the initial application.

If we say “Ansible modules are idempotent” it conveys that if the requirements are pre-installed then no changes would be made.

We have Handlers for analysing the changes.

Handlers are the tasks in Ansible which contains notification directives. They indicate if changes are made. When changes occur , it is notified to handlers and the task is done.

REQUIREMENTS

  1. Controller Node
  2. Manager Node

I have created an Ansible playbook on controller node to configure httpd server on target nodes. This will help us to monitor the idempotence nature of Ansible.

Code:

Run the Ansible Playbook -

Command: ansible-playbook <file_name_with_extension>

On executing the program for the first time changes are notified in conf file. Without changing the code when again we run the sam playbook no changes are encountered. The handler didn’t run. Since we didn’t make any changes the services didn’t restart.

Happy Learning!

Happy Sharing!

--

--

Bhavna Surendra Latare

I am a student passionate about Programming and Development | DSA Enthusiastic | working on ML | exploring Indian Culture