❗ Idempotence in Ansible

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

Lets see how we can rectify this challenge ….

🟥Using when Keyword: Conditional expression, determines if an iteration of a task is run or not…..

🟥Using handlers : Handlers are just like regular tasks in an Ansible playbook (see Tasks) but are only run if the Task contains a notify directive and also indicates that it changed something. For example, if a config file is changed, then the task referencing the config file templating operation may notify a service restart handler.

✍While ,we copy webpage to directory /var/www/html(root_document)
we have register the variable : rootdoc which will keep track of changes / updation made in directory

👉 Now we have rootdoc as notifier , we can use this in the when keyword , that is if we have changes to directory restart the service else leave it untouched if running ……

Thus , we can achieve idempotence using WHEN keyword

The entire playbook is wriiten as followed :

🎫Github link : Idempotemce_httpd

Keep learning …..🎁

Keep Motivating 🏆

Technological Enthusiast , Like to express what is need of time, Relates real world to philosophical insights