Making httpd serviceIdempotent Using Ansible
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..
- install httpd using package module of ansible
- copy the webpages to the document root that is /var/www/html by default
- add a notify in this copy module for a handler that does restart the services
- add a firewall rule for port 80 that is default port for httpd so that we can see the webpages
- 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
- 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 :