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

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.

Idempotent Playbooks:

When a playbook is executed to configure a system, the system should always have the same, well defined state. If a playbook consists of 10 steps, and the system deviates in step 4 from the desired state, then only this particular step should be applied.

By its nature, Ansible tasks will only change the system if there is something to do. Most Ansible modules provide this idempotency. But some modules can be used in a way that breaks this pattern.

For example: When we run playbook to configure httpd apache webserver, there the httpd service will always start no matter if it is already started in target node. This means that it doesn’t allow idempotancy.

The problem of idempotancy we need to rectify.

To rectify this issue either we can use the when condition which allows to start the service when the condition matches (condition : if httpd listen port changes to other port number) or can use handlers and notify concept which states that when the particular task done the notify will trigger the handlers block of code.

Let’s look into playbook code:-




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

Recommended from Medium

DNS lookup timeouts in Kubernetes

Programming as Theory Building by Peter Naur (an excerpt)

NET Core vs NET Framework Comparison with Pros and Cons

.NET Core vs .NET Framework Comparison

Migrating Selenium Project From .NET Framework To .NET Core

Tendermint 0.34, Protocol Buffers, and You


C++ STL Library

iROID the top Website development company in India

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
Mukul Jeveriya

Mukul Jeveriya

More from Medium

Project 2: Rhino and the CNC Router

Layer 1 & 2 — Scalability

Can’t we all live in cities?

Go behind the curtains with #InsideTeamApt