How to make Httpd service idempotence in nature | Technical EJ - Latest Technology News

Sunday, 21 March 2021

How to make Httpd service idempotence in nature

  Ekansh Jain       Sunday, 21 March 2021

Today's Task: Restarting httpd Service is not idempotence in nature and also consumes more resources suggests a way to rectify this challenge in the Ansible playbook

Let's see how you can make httpd module idempotence in nature.

To solving the above problem, we will use two keywords in our ansible-playbook.

Keywords used to make httpd service is idempotence are as follows:-

1) Notify 

2) Handler

Steps to be followed:-

1) To show the successful output, first I will stop my httpd service.


2) Write the code using notify and handler keywords.

Handlers are the tasks that run when tasks are notified.

Notify is the keyword that is applied with the services, it works with handlers.

Handlers should have a unique name with respect to notify the keyword.


3) Now Run the playbook


Now, the httpd module restarted because we had changed the port number.

4) Now, if we run the playbook again, the httpd service won't restart because the port number is the same as the previous one. If we change the port number, then the httpd service will restart with the help of notify and handlers.

5) See the above image, the httpd module has not started again as the port is the same as the previous one.

Conclusion

Hence, restarting the httpd Service is now idempotence in nature in the Ansible playbook.

logoblog

Thanks for reading How to make Httpd service idempotence in nature

Previous
« Prev Post

No comments:

Post a comment

If you have any doubts, Please Comment down