Make Restarting HTTPD Service idempotence

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 ) -

No alt text provided for this image

* Ansible Configuration File -

No alt text provided for this image

* Inventory file -

No alt text provided for this image

* httpd configuration file "govind.conf" is - ( ansible_default_ipv4.address , DocRoot are variables in ansible playbook )

No alt text provided for this image

* ( I will put firewalld service in STOPPED state )

# systemctl stop firewalld
# systemctl status firewalld
No alt text provided for this image

* I will create playbook "HttpdSetup.yml" in "/httpd/" directory -

No alt text provided for this image

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

No alt text provided for this image

In my case nothing change in my Httpd configuration file so "handler" task will not run.

Now I am changing "DocumentRoot" -

No alt text provided for this image

* Now run again playbook -

No alt text provided for this image

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

要查看或添加评论,请登录

社区洞察

其他会员也浏览了