Restarting HTTPD is not Idempotence in Nature

Mahima jindal
3 min readDec 9, 2020

--

Ansible is simple open source IT engine which automates application deployment, intra service orchestration, cloud provisioning and many other IT tools. Ansible is easy to deploy because it does not use any agents or custom security infrastructure.

Today we gonna discuss about Why Restarting HTTPD services is not Idempotent and also gonna solve this issue.

So firstly we should talk about Idempotent Nature….

Idempotence means after 1 run of a playbook to set things to a desired state, further runs of the same playbook should result in 0 changes.

Why we need to Restart HTTPD services again..?

Its because when we make some changes in Configuration file of Managed node through Ansible playbook , just after that we need to Restart httpd services .

Solution

To solve this issue of restarting services through playbook only we can make the use of Handlers in our playbook .

what are Handlers..??

Handlers are just like normal tasks in an Ansible playbook but they run only when if the Task contains a “notify” directive. It also indicates that it changed something.

Lets start…

✦ Firstly we have to configure Inventory where we will store the details of all the Managed Nodes that we want to configure.

Now after that we have to update this inventory file in the Configuration file of ansible so that ansible will come to know that which nodes it has to configure.

✦ Updating Inventory in Config file of Ansible

✦ Check the available hosts

After all these above steps we finally have to write the playbook to configure what we want.

✦ Playbook writing

Here in this playbook I have used ansible.posix.selinux collection so that I can disable the SElinux security in Managed Node .

So to use this collection , it must be installed on your Controller Node

And this is the Change.conf file which I used in playbook. In this file we have mentioned the Document root and the port Number that we need to change.

✦ Run the Playbook

We can see playbook ran successfully.

✦ Verify the configuration by manually going to managed node

We can see that configuration is successfull.

✦ Check the site on browser

We can see our site successfully.

Thank you !!

--

--