Working With Ansible Service Handler
- Our setup-lb.yml & setup-app.yml playbooks restart apache service whenever will run the playbook even there are no changes made it
- We can avoid getting apache service restart we can use service handlers
- Modify your playbook accordingly setup-app.yml & setup-lb.yml
- Lets add one more playbook to check status of services
vim check-status.yml
- Content of setup-app.yml, Click Here!
- Now lets stop apache service on our loadbalancer by:
ansible -m service -a "name=httpd state=stopped" --become loadbalancers
- Now run your playbook with:
ansible-playbook check-status.yml