In this blog, we are going to solve one problem and that problem is "Restarting HTTPD Service is not idempotence in nature and also consume more resources"
So let's solve this problem:
The task that we are going to perform in this blog are:
- Create an Ansible playbook to configure yum in the managed node.
- Install apache webserver httpd in the managed node.
- Configure the webserver.
My setup is something like this👇
Now create an Inventory
Create an Inventory anywhere in the system, here I have created an inventory named ip.txt.
Now check the connectivity with Managed Node using the command ansible all -m ping
Now create an ansible configuration file.
Now create a configuration file for htttpd
Here I have created a configuration file named httpd.conf
Now Create an Ansible Playbook
In this playbook, we have configured yum, installed httpd, and configured it.
Now before running the playbook let's check in the managed node whether yum and httpd is configured already or not...
- To check whether yum is configured or not use command yum repolist
Here you can it is not configured.
- To check whether httpd is installed or not use command rpm-q httpd
Here you can see httpd is not installed
Now run the playbook
Here you can see the playbook run successfully....
Now check in the managed node, changes that we did using ansible are done or not.
- let's check yum is configured or not, we can check that using command yum repolist
now you can see that it is configured successfully....
- check httpd is installed or not, we can check that using command rpm -q httpd
Now you can see it is installed successfully....
- check whether the configuration file is placed in managed node or not.
Here you can see httpd.conf that we created is placed and configured successfully...