Apache HTTPD server : Apache HTTPD is an HTTP server daemon produced by the Apache Foundation. It is a piece of software that listens for network requests (which are expressed using the Hypertext Transfer Protocol) and responds to them.
Ansible : Ansible is an open-source software provisioning, configuration management, and application-deployment tool enabling infrastructure as code. It runs on many Unix-like systems, and can configure both Unix-like systems as well as Microsoft Windows. It includes its own declarative language to describe system configuration.
Our problem: On running the below playbook, which is created to install and set up httpd server in the target node through ansible,
This is the playbook created,
Now we will run the playbook, and let’s create a problem.
Here our playbook runs successfully, but at the service start we will find that it will be restarted again and again after re-run, So after every small change in the playbook we have to go through our complete setup down and loss of connection between the user and the site, So, we have successfully created the problem.
As expected above, the complete server restarted and the there would be disconnectivity between client and server.
Now, let’s talk about solution, Look at the below code,
It’s the same code with just two additional lines, So what these lines stand for, let’s understand.
Here, “register : x” is a variable which is storing the changes in the above task, which means if task is changed or ok,(acc. to ansible),Where as in the last line “when: x.changed == true” stands if the value of change in the register x is true then run this task else skip it, Now, let’s check the output.
We are successful, the service start is skipped because package is already installed.
Thank you for reading !!!