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

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

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

Target ip where we performed our task

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.

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!”

- 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
- We have created doc_root file using file module
- We updated configuration file into /etc/httpd/conf.d/confFile.conf for this we used template module.
- By using copy module, we were copied content from the controller node.

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 😉