🔰 11.3 Restarting HTTPD Service is not idempotence in nature and also consume more resources suggest a way to rectify this challenge in the Ansible playbook.
We all are in a hurry, we want to save our time, we want to make a profit, we want to make our work automated, and many more …
Ansible is a solution to many problems because it saves time and money.
Ansible is a Configuration Management tool that also does Provisioning, Orchestration, etc.
Ansible is Open-Source and free.
Today in this blog I am making the “ restarted ” state Idempotent. Though Ansible provides idempotency still some of the services do not follow idempotency so by some trick we will make it idempotent.
— — — — — — — — — — — — — — — — — — — — — — — — — — — — —
- To make the code user-friendly it will ask for the folder name where the DVD needs to mount.
- The path where configuration files need to be copied up.
- The port number where the webpage should run.
- Create the directory so that DVD will be mounted there.
- Configure yum so that the httpd service will be installed.
- Install httpd service.
- Configure the httpd configuration file.
- Set the default directory.
- Handlers will run the service only when notify will say that some changes are made.
RUN THE ANSIBLE PLAYBOOK -
“ansible-playbook file.yml” is the command to run the ansible-playbook.
SEE THE CHANGES MADE -
This file was run for the first time that’s why it makes changes.
When the code was rerun it does not run the httpd service as it was already in a running state and also we have not made any changes to the webpage.
HTTPD SERVICE ENABLED-
HTTPD service is in an active state.
This is the DVD directory where the “ /dev/cdrom “ is mounted.
This is the output when we tried to access the webpage with the IP of the device and the given port number.
THANK YOU FOR READING !!
GITHUB LINK — https://github.com/manali1230/Add-Idempotency.git