---
# tasks file for apache_virtual_host
- name: create virtual host file
template: src=apache.conf dest="/etc/apache2/sites-available/{{ virtual_host }}.conf"
- name: create virtual host file2
template: src=apache2.conf dest="/etc/apache2/sites-available/{{ virtual_host }}2.conf"
And here are the two src files from role/template/. Notice the second does not have {{ foo }}
apache.conf:
<VirtualHost *:80>
ServerName {{ virtual_host }}
ServerAlias: {{ foo }}
</VirtualHost>
apache2.conf
<VirtualHost *:80>
ServerName {{ virtual_host }}
ServerAlias:
</VirtualHost>
And here are the result files where virtual_host is defined to be foo.com, but foo is not defined:
foo.conf
<VirtualHost *:80>
ServerName {{ virtual_host }}
ServerAlias: {{ foo }}
</VirtualHost>
foo2.conf
<VirtualHost *:80>
ServerName foo.com
ServerAlias:
</VirtualHost>
Notice that in the foo.conf file, NO SUBSTITUTION OCCURRED AT ALL even though virtual_host is defined.
I was very careful to remove the destination files on the target system so that the template was triggered.
Any help debugging this greatly appreciated
John
ansible-playbook 2.2.1.0