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

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
name: "httpd"
state: present
- name: creating document root file
state: directory
path: "{{ doc_root }}"
- name: updating conf file
dest: "/etc/httpd/conf.d/confFile.conf"
src: "confFile.conf"
- name: copying content
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.






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