Make HTTPD Service idempotence in Nature using Ansible

Make HTTPD Service idempotence in Nature using Ansible

ARTH - Task 11.3.

Task Description:

?? 11.3 Restarting HTTPD Service is not idempotence in nature and also consume more resources to suggest a way to rectify this challenge in Ansible playbook.

Let's solve this problem by performing some task:

  • Create an Ansible playbook to configure yum in the managed node.
  • Install apache webserver httpd in the managed node.
  • Configure the webserver.

Ansible Configuration File

#vim /etc/ansible/ansible.cfg

No alt text provided for this image

In the above ansible.cfg file mention, the path of the inventory file and also mention that host key checking is false.

Ansible inventory file:-

The Ansible inventory file defines the hosts and groups of hosts upon which commands, modules, and tasks in a playbook operate. The file can be in one of many formats depending on your Ansible environment and plugins. ... If necessary, you can also create project-specific inventory files in alternate locations.

No alt text provided for this image

Now check the connectivity with Target Node using the command 

# ansible all -m ping

No alt text provided for this image

Create a configuration file for httpd

Here I have created a configuration file named httpd.conf

No alt text provided for this image

and the variable stored in the http_var.yml file

No alt text provided for this image

Create an Ansible Playbook:

No alt text provided for this image
No alt text provided for this image

In this playbook, we have configured yum, installed httpd, and configured it.

Now run the playbook

# ansible-playbook httpd_yum.yum

No alt text provided for this image
No alt text provided for this image

Here you can see the playbook run successfully.

  • let's check yum is configured or not, we can check that using the command

# yum repolist

No alt text provided for this image

now you can see that it is configured successfully.

  • check httpd is installed or not, we can check that using command

# rpm -q httpd

No alt text provided for this image

Now you can see it is installed successfully.

  • check whether the configuration file is placed in target node or not.
No alt text provided for this image

Here you can see httpd.conf that we created is placed and configured successfully.

Thank You....









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

Anand Kumar的更多文章

社区洞察

其他会员也浏览了