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

Before start practical, we are checking connectivity

Avadhut Shinde
3 min readMar 22, 2021
checking connectivity
ansible all -m ping

let’s being 😁

If we want to install any package into a target for this, we have to configure yum. before yum we have to mount RedHat 8 dvd. DVD content package and for this, we used to modules

1) file : This module helped us to create file for mounting dvd.

, 2) mount: Mount module content source path, state, and type

var file

In our ansible-playbook we have used varible, for this we created sperate file.

target ip

Target ip where we performed our task

configuration file

In the above image, there is a configuration file that allows customized of the server. We are changing the port number and, document root file as per our requirement. and we used ansible facts that help us to change IP dynamically.

yum configuration

We mounted DVD, mounting DVD won’t help us to install package for this we need to configure yum and above image content “how to configure YUM!

package install
- name: installing httpd package
package:
name: "httpd"
state: present
- name: creating document root file
file:
state: directory
path: "{{ doc_root }}"
- name: updating conf file
template:
dest: "/etc/httpd/conf.d/confFile.conf"
src: "confFile.conf"
- name: copying content
copy:
dest: "{{doc_root}}/index.html"
src: /task_11/as.html

Now we are installing httpd package, order to install we have to follow 3 steps after installation

  1. We have created doc_root file using file module
  2. We updated configuration file into /etc/httpd/conf.d/confFile.conf for this we used template module.
  3. By using copy module, we were copied content from the controller node.
firewall rule and service

We are going to set firewall rule for security purpose because other traffic won’t harm our server. firewalld module allows setting rules. for this we giving the port number. We have changed the configuration file and if we want to change to apply for this we need to restart the service all time. for this we have used the service module, The in-service module we have option to restart the service.

PLAY-BOOK RUNNING

WE HAVE SUCCESSFULLY RUNNING PLAY-BOOK….

THANKS FOR READING 😉

--

--