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

New Story

Rise/Need of Big Data Systems

Among us game animation using Flutter

My Experience at LGM-SOC’21

Automation: Are we looking at the next evolution of APIs?

Introducing Helm: The Kubernetes Package Manager

Customer Development in DeFi

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

“Our key to success is knowing that network better than the people who set it up.” — Rob Joyce

The EYFS is changing. Part 2: Community Engagement at Beach Babies

A Biker’s Take on Covid 19.

Yum configuration in Redhat (RHEL)