🔰 Restarting HTTPD Service is not idempotence in nature 🔰

Idempotency:

An operation is idempotent if the result of performing it once is exactly the same as the result of performing it repeatedly without any intervening actions.

In general, idempotence is “the property of certain operations in mathematics and computer science that can be applied multiple times without changing the result beyond the initial application.

Here to Start httpd service we will take help of ansible.

What is ansible ?

Ansible is a popular IT automation engine that automates tasks that are either cumbersome or repetitive or complex like configuration management, cloud provisioning, software deployment, and intra-service orchestration.

What is ansible playbook ?

An Ansible playbook is a blueprint of automation tasks — which are complex IT actions executed with limited or no human involvement. Ansible playbooks are executed on a set, group, or classification of hosts, which together make up an Ansible inventory.

Here we created a ansible playbook for configuring httpd server without idempotence code

Source code for not ideam

when we run this ansible playbook all task will be installed and configured in target node green color in output showing nothing to change no wrok done

If we again run this play book it will restart the service even if service is started.

Yellow color in output is showing that every time cpu is using resource to restart service even if service is started.

BY THIS WE WILL GET TO KNOW THAT HTTPD SERVICE IN NOT IDEMPOTANCE IN NATURE

To make this service Idempotance we will change code or can say we will add handler module which will check if service is started or not if it is already running then it will skip the task and will do nothing but whenever we will do some changes in file here i can say confg file.

Then our notify module will tell or notify handler that some change is done so now to apply this change you have to restart service so the service will restart.

ANSIBLE PLAYBOOK FOR IDEMPOTANCE

Now we will do some changes in new_file.confg and our handler and notify module will work

Now we have Listen 80 this code in our .confg file

We now do some changes in this .confg file listen 8080

Now run playbook again and we will see some changes done in file that we can see in output yellow color “changed” indicate this some changes has done.

If now we will run playbook then it will show “changed = 0” with green color output but when we were using notideam.yml playbook every time it show some changes because i restart service even if service is started but here it will do nothing if service already running.

LIKE THIS WE CAN ACHIVE IDEMPOTANCE NATURE USING ANSIBLE PLAYBOOK

THANK YOU

ENJOY CODING