Latest Updates

Make web server idempotent with ansible


 What is Idempotence ?

In general, Idempotence is “the property of certain operations in mathematics and computer science that can be applied multiple times without changing the result beyond the initial application”.


Understand Handlers?

Handlers are just like normal tasks in an Ansible playbook but they run only when if the Task contains a “notify” directive. It indicates that it changed something. And when any change is detected then it notifies the respective handler and the task completes.

Task Objective:-

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

Let’s get Started

First, check your Web server is running or not by using the following command

systemctl status httpd




Listen {{ Port }}<VirtualHost {{ansible_facts['default_ipv4']['address']}}:{{Port}}>
DocumentRoot {{ Document_root }}
</VirtualHost>




ansible-playbook "playbook-name.yml"




our playbook executed successfully, But if you see in the above image I have changed firewall rules this time but not changed anything in the web server configuration but it is restarted again for no reason.

  1. handlers


No comments