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 problem, we can use Handlers

Handlers in ansible to be triggered only when there are some changes occur in particular file (any file, can be configuration file also) and then handler will do the task accordingly

Sometimes you want a task to run only when a change is made on a machine. For example, you may want to restart a service if a task updates the configuration of that service, but not if the configuration is unchanged. Ansible uses handlers to address this use case. Handlers are tasks that only run when notified. Each handler should have a globally unique name.

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 keyword in ansible.

Creating a playbook to configure yum and intalling httpd package, wrting the webpage and to start httpd services

Runing the Playbook:

Giving the document root name as /var/www/main and port no as 84

Again running the same playbook with same document root name and port no; as there is no changes in configuration file of httpd so no need to restart the services (handler will do this for us)

Thank you for reading!




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

Developing a Platform on a Shoestring Budget

Jack Peterson: Hi @wireshape_admin Welcome to Crypto King. We are proud to have you here today 🎉

Drift Protocol Public Devnet Launch and Learnings

Introduction to object-oriented programming — Tech 101

An API upgrade post-mortem

Test your RabbitMQ as MQTT broker in a local environment

Why Don’t Mobile App Developers Use Logs?

Companies That Use Node.js for Backend: How Do Big Players Benefit from It?

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
Adithya Gangadhar Shetty

Adithya Gangadhar Shetty

More from Medium


When networking is not what networking used to be

“New Ulm’s Bestseller”

What makes a product good rather than great?