Restarting httpd Service is not idempotence in nature and also consume more resources suggest a way to rectify this challenge in the Ansible playbook

Jaindivya
3 min readJul 3, 2021

--

What is an Ansible playbook?

Ansible Playbooks offer a repeatable, re-usable, simple configuration management and multi-machine deployment system, one that is well suited to deploying complex applications. If you need to execute a task with Ansible more than once, write a playbook and put it under source control. Then you can use the playbook to push out new configurations or confirm the configuration of remote systems.

What is Apache Webserver?

The Apache HTTP Server, colloquially called Apache, is a free and open-source cross-platform web server software, released under the terms of Apache License 2.0.

Challenges faced :

In the webserver with the ansible, we have one challenge i.e., whenever our system restarts we need to run ansible-playbook again and again to restart the services of HTTPD.

Step-1

>>Do entry of webserver node in the inventory file and check connectivity

Check the ansible connectivity by using ansible all -m ping

The playbook is as follows

- hosts: all
tasks:
- name: "Install httpd"
package:
name: "httpd"
state: present


- name: "Create File"
copy:
dest: "/var/www/html/index.html"
content: "<br> <h2> This webpage created by ansible </h2> <br>"


- name: "Start Services"
service:
name: "httpd"
state: started
enabled: yes

Run the ansible-playbook as shown below

See we have started the service successfully and we have enabled it permanently

Check in the webserver if the service is installed as follows

Voila !! This is the Website that we have launched successfully!!

There is no need to run the playbook again and again and restart the service.

We have achieved it!!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response