Making Restart of Httpd Service Idempotent in Ansible Playbook

General Approach for Restarting httpd services

#service module inside the tasks block
tasks:
- name: service httpd
service:
name: "httpd"
state: restarted

Restarting Httpd services using Notify and Handler

tasks:
- name: Copy conf file
template:
src: "local_conf.conf.j2"
dest: "/etc/httpd/conf.d/web.conf"
notify: service httpd #Whenever the conf file is changed it
notifies the task in handler to run
#The task inside handler runs only when notified
handlers:
- name: service httpd
service:
name: "httpd"
state: restarted

--

--

--

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

Recommended from Medium

RAPIDS 0.15 Release

This week in DevOps — Issue #6

Deploying WebServer Infrastructure on AWS with S3 implementation and Cloudfront using Terraform

What are some of the advantages of using the Spheron platform?

Building the Super Tiny Compiler with Reason (part 1)

Fonts For Developer 2.1

Add Log Decorators to Your Python Project

Keyscape

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
Juzer Patanwala

Juzer Patanwala

More from Medium

CS371p Spring 2022 Blog # 7: Jeffrey Liu

Application Framework

How to create a Lambda function, Java 8, AWS Lambda, SAM CLI and testing/debuging locally.

Start your technical journey of AWS. As a programmer let’s work on AWS CLI