Restarting httpd Service is not idempotence in nature and also consume more resources this is a way to rectify this challenge in the Ansible playbook
What is Ansible?
Ansible is a software tool that provides simple but powerful automation for cross-platform computer support. It is primarily intended for IT professionals, who use it for application deployment, updates on workstations and servers, cloud provisioning, configuration management, intra-service orchestration, and nearly anything a systems administrator does on a weekly or daily basis. Ansible doesn’t depend on agent software and has no additional security infrastructure, so it’s easy to deploy.
What is Ansible Playbook?
Playbooks are the files where Ansible code is written. … Playbooks are one of the core features of Ansible and tell Ansible what to execute. They are like a to-do list for Ansible that contains a list of tasks. Playbooks contain the steps which the user wants to execute on a particular machine
Pre-requisite for this task :
Two RHEL OS on your system with yum configuration.
- Controller Node
- Managed Node
let me show you to inventory file
and you can also see that I can ping to the Controller Node
let's see the Playbook now
In this playbook
STEP 1
I have added a group “all” in the option given by host ,So that if in future I can add one more IP in inventory , I can easily choose to which group it should be fitted for our purpose .
Tasks
STEP 2
Installing Httpd package by using package module .
Installing httpd Package
STEP 3
Copying the Web Page to the document root using copy module
STEP 4
Starting the Httpd service ,using the service module and instead of using attribute restarted ,I am using started .
Because started attribute in service module is idempotence in nature.
Starting the service
STEP 5
Creating a firewall rule for the port no 80 running with protocol tcp.
Creating a firewall rule
After running the command
ansible-playbook internet.yml
let's again run the Playbook
since the “started” is in idempotent in nature
we can see that “changed=0”
Connect me on my LinkedIn as well.