How to make services module of Ansible Idempotence in nature.
Hello readers, Hope you all are doing well in this lockdown period. Today I bring a blog for you in which I will tell you, that how can you make your services Idempotence, So that every time you run your playbook it’s services won’t restarted again.
So for this blog I am taking example of Apache Httpd server, It is conveys very bad impression when updating a minor bugs lets your webserver to be restarted. But When we use ansible playbook with service as a restarted option, every time the playbook runs it restarted the webserver, Which is not good thing for us.
To overcome from this issue, We guys are going to use handlers today, such that so whenever any major changes take place it only restart the playbook then only.
I am also attaching GitHub link for complete playbook here -
Run the playbook using “ansible-playbbok webserver.yml” command.
When We run our playbook for very first time it started the webservice as the code is new for it. Let’s try to run the same playbook again.
Now you can see that This time our service hasn’t restarted for webserver. Let’s try exploring the website.
Now Let’s run the same playbook after changing the webpage a little.
Now you can see that as the code changed the handler started working. So finally we achieved our goal of making ansible playbook idempotence in nature.
Thanks For reading this Small Blog, Hope you find it helpful.