CONFIGURATION OF APACHE WEBSERVER USING ANSIBLE
🔰 Task Description📄
Restarting HTTPD Service is not idempotence in nature and also consume more resources , suggest a way to rectify this challenge in Ansible playbook
Solution :
◾Automate the Ansible Playbook with Handlers..
Handlers for Apache Web Server
Handlers are just like regular tasks in an Ansible playbook but are only run if the Task contains a notify directive and also indicates that it changed something. For example, if a config file is changed, then the task referencing the config file templating operation may notify a service restart handler.
Handlers will play a vital role in restarting the httpd server. when there is some change in the code then only the apache webserver will restart again. This will reduce the time taking by other servers.
🔰 STEPS:
- Setup the Controller Node.
Create Inventory file and ansible config file .
Now , check connectivity with managed node.
2. Now, Create a variable file that store all the variable of playbook.
3. Now, create a http .conf file.
4. Now , write the code in playbook.
Install httpd software, then start services, then copy config file ...
5. Before running the playbook , check syntax ….
Run the playbook .
Handlers only restart the service , if there is any change in configuration file , if there is no change then it save the resources.
6. Now to check setup in managed node.
index.html file is created .
http.conf file is created
Now , to check webpage .