I have a single Ansible-provisioned server running a number of sites.
My Ansible tasks look roughly like:
- name: site nginx config
template: src="nginx-site.conf.j2" dest=/etc/nginx/conf.d/{{item.name}}.conf
owner=root group=root mode=0444
with_items: sites
notify: restart nginx
- name: nginx conf
template: src=nginx.conf.j2 dest=/etc/nginx/nginx.conf
owner=root group=root mode=0444
notify: restart nginx
I'd like to use the validate
parameter to Ansible's template module to call nginx -t
and make sure my new configs are syntactically valid. It works for the main nginx.conf:
template: src=nginx.conf.j2 dest=/etc/nginx/nginx.conf
owner=root group=root mode=0444
validate="/usr/sbin/nginx -c %s -t"
But it doesn't seem to pick up changes to the site-specific config files. Putting validate
on the site-specific templates doesn't work, as they need to be wrapped in an http
directive to be valid.
What can I do to check the validity of these site-specific files?