Making the HTTPD service Idempotent using Ansible | Task-11.3 | Arth |

What is Idempotence

By Idempotence nature we mean a task only happen when there is a need.
Whenever we run our ansible file with service module we can do two type of operation either start every time or when the service is not started.
But if our requirement is that whenever there some changes occur in the code file then the httpd services restart.
In this case the above feature is called Idempotence nature.


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


There is only one step to achieve Idempotence & that is use of Handlers module with service module. We set notify module with template task so that if any changes occur there the service task run.

Now let’s run this play-book.

You can see there 3 changes occur & as template task run the handler task also run.

Now i haven’t change anything, let’s run this play-book again.

You can see there no change occur and even handler task also didn’t run.

Let’s see our webserver working or not.

Now let me do some change in the file & then run this play-book.

Here we can see two changes occur. Let see the webserver to confirm we are in right direction or not.

So the website changes it’s content & we achieve idempotence.

!!!Thanks For Reading The Article!!!




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

A SuperDeclarative! perspective on Flutter Engage

What are Optional Chaining , Optional Binding and Use of Guard key in Swift

Game Making Tool Research: Unity 2D Game Design

Infrastructure Diagrams as Code Is Possible?

Flutter : RaisedButton Widget

How Russians Hack [and how to contribute to a hackathon team as a newbie]

Nuvola 4.24 fixes Spotify, Deezer and Yandex Music

Ansible and Its Use Cases

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Gaurav Sharma

Gaurav Sharma


More from Medium

yojenkins — A User-Friendly Command Line Interface Tool for Jenkins

Using Aliyun-CLI with Docker Very Easily

Git for Beginners Part Three— Git it “on” with Github

Checkov extension in VSCode