Making httpd serviceIdempotent Using Ansible

Ayush Laxkar
2 min readMar 21, 2021

--

httpd is the Apache HyperText Transfer Protocol (HTTP) server program. It is designed to be run as a standalone daemon process. When used like this it will create a pool of child processes or threads to handle requests.

When we setup httpd server then each time when new code come up we have to restart services manually we can make the httpd restart idempotent using the ansible’ s concept named as notify and handler.

Steps to create a playbook that will do the same..

  1. install httpd using package module of ansible
  2. copy the webpages to the document root that is /var/www/html by default
  3. add a notify in this copy module for a handler that does restart the services
  4. add a firewall rule for port 80 that is default port for httpd so that we can see the webpages
  5. write a handler having any name but be sure to use same name in the notify statement and in this handler write state of httpd as restarted
  6. now whenever new code come up write that code file in the src field of thecopy module and when we will run the playbook it will automatically trigger the handler to restart the service of https.

Below are the ss that show my playbook executin and the github link for the code

Github Link for the playbook :

https://github.com/CodeWithMe26/makingHttpdRestartIdempotent

--

--