Check Apache HTTP config before reloading
If making any changes to the Apache HTTP config, be sure to test the config before reloading. Force failure when there is a problem.
- name: Apache | Enable the new site
command: a2ensite site-name creates=/etc/apache2/sites-enabled/site-name
- name: Apache | Check the apache configuration
command: apache2ctl configtest
register: apache_result
ignore_errors: yes
- name: Apache | Reverting - Disable new site
action: command a2dissite site-name
when_failed: $apache_result
- name: Apache | Reverting changes - Ending playbook
action: fail msg="Apache configuration is invalid. Please check before re-running the playbook."
when_failed: $apache_result
- name: Apache | Reload Apache
service: name=apache2 state=reloaded
Written by Brad Erickson
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ansible
Authors
Misha Behersky
78.96K
tartansandal
73.31K
Related Tags
#ansible
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#