Make Restarting HTTPD Service idempotence
ARTH - Task 11 ???????
Task Description??
?? 11.3 Restarting HTTPD Service is not idempotence in nature and also consume more resources suggest a way to rectify this challenge in Ansible playbook
Introduction to ANSIBLE -
We can do automate any configuration of server by two ways-
> 1). Traditional Way ( With Imperative Language) - In this way we use imperative language scripts (like python , perl etc,) script to do something automate. In this way we have to tell "What to do" and "How to do". It is not so much intelligent way to do automate.
> 2). With Declarative Language - In this way we use declarative languages (like Ansible , Puppet etc,) to do automate. In this way we have to tell only "What to do". It is so much intelligent. It knows "How to do". In this article We will know about Ansible.
*Ansible is tool which is used for Configuration Management (CM). In Ansible we only tell to "what to do". We don't need to tell "How to do" because Ansible already knows that "How to do this task" on each type of Operating System . This intelligence of Ansible comes from "modules" . Modules know "How to do this operation on each OS". We don't require to tell particular OS command. Ansible don't perform any operation on OS. It is done by respective OS command. Ansible module know which command is required to run on OS to do this.
* For this practical I have to Virtual machines ( Controller Node - 192.168.43.53 Managed Node - 192.168.43.129 ) -
* Ansible Configuration File -
* Inventory file -
* httpd configuration file "govind.conf" is - ( ansible_default_ipv4.address , DocRoot are variables in ansible playbook )
* ( I will put firewalld service in STOPPED state )
# systemctl stop firewalld # systemctl status firewalld
* I will create playbook "HttpdSetup.yml" in "/httpd/" directory -
> Here "notify" & "handlers" keyword are used to make "Restart Httpd service Idempotance"
If anything change in configuration file the "notify" keyword will notify to handlers other this handler will not run.
* Run "HttpdSetup.yml" playbook -
In my case nothing change in my Httpd configuration file so "handler" task will not run.
Now I am changing "DocumentRoot" -
* Now run again playbook -
In this case "DocumentRoot" changed so httpd configuration file "govind.conf" will also change so Handler task will run.
We have done this task successfully