🔰11.3 Restarting HTTPD Service is not idempotence in nature and also consume more resources suggest a way to rectify this challenge in Ansible playbook”

To solve this issue we take the help of Handlers.

What is Handler?

Handlers are just like a normal task. Handlers will perform an action when listens for a notify event. If nothing notifies a handler, it will not run. Regardless of how many tasks notify a handler, it will run only once, after all of the tasks completed in a particular play.

Handlers in ansible to be triggered only when http configuration file changes and then handler will restart httpd service.

If you run the playbook again then it will shows that Your service is started so no need the restart again this become possible because of the handlers and notify keyworks in ansible.

Handlers are just like regular tasks in an Ansible playbook but are only run if the Task contains a notify directive and also indicates that it changed something. For example, if a config file is changed, then the task referencing the config file templating operation may notify a service restart handler.

This means services can be bounced only if they need to be restarted. Handlers can be used for things other than service restarts, but service restarts are the most common usage.

Run the playbook :-

When there is change in the configuration file then the httpd service needs to be restarted.

In the end we have a handler running.

But if we run the playbook without any changes in the configuration file then there’s no need to restart the service and so the handler doesn’t executes.

So by this the problem can be resolved.

So Now our task is completed :)

GitHub Link :

--

--

--

computer engineering

Love podcasts or audiobooks? Learn on the go with our new app.

Jenkins Dynamic Clustering

Should CockroachDB be taught at universities?

#10 - List of popular Software Development methods with their features, advantages and…

Implementing a Chatbot in Django

CS373 Fall 2021 Week of 18 Oct — 24 Oct: Victor Xia

Building a File Upload Service to your Google Drive using OAuth 2.0

Why you shouldn’t create webview-only apps

Interacting with AWS Aurora Serverless

Photo Credit European Space Agency Astronaut Samantha Cristoforetti. https://www.nasa.gov/mission_pages/station/expeditions/expedition42/gallery.html

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
shivanand Patil

shivanand Patil

computer engineering

More from Medium

CS371p Spring 2022 Blog # 13: Jeffrey Liu

Mateusz’s best monthly reads 11/2021 — 1st edition

Singpass Login API Integration-part 1

How to make a Network Diagram and why every organisation should