Hello,
if someone can assist, it would be helpfull. I am trying to loop over
vhosts and generate one config per vhost but I'm ending with multiple conf
files with all vhosts in inside.
This is the setup:
VARS
apache_vhosts:
- servername: www.domain.com
apache_vhost_listen_ip: '*'
apache_vhost_listen_port: 80
serveralias:
- domain.com
- test.domain.com
etc.
- servername: www.otherdomain.com
apache_vhost_listen_ip: '*'
etc.
TEMPLATE:
<VirtualHost {{ item.apache_vhost_listen_ip }}:{{
item.apache_vhost_listen_port }}>
ServerName {{ item.servername }}
ErrorLog */var/log/httpd/*{{ item.servername }}-error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog */var/log/httpd/*{{ item.servername }}-access.log combined
</VirtualHost>
TASK:
- name: Create apache vhosts
template: src=vhost.conf.j2 dest="/etc/httpd/conf.d/vhost-{{
item.servername }}.conf" owner=root group=root mode=0644
with_items: "{{ apache_vhosts }}"
This creates multiple "vhost-servername.conf" files with all vhosts in them
Do you have any idea? I tried replacing "with_items: apache_vhost" per
instruction here:
https://groups.google.com/forum/#!topic/ansible-project/DWOwJOyga24
But ansible nags and pops the error:
TASK [httpd : Create apache vhosts]
********************************************
fatal: [hostname]: FAILED! => {"failed": true, "msg": "the field 'args' has
an invalid value, which appears to include a variable that is undefined.
The error was: 'unicode object' has no attribute 'servername'\n\nThe error
appears to have been in '/somepath/roles/httpd/tasks/main.yml': line 34,
column 3, but may\nbe elsewhere in the file depending on the exact syntax
problem.\n\nThe offending line appears to be:\n\n\n- name: Create apache
vhosts\n ^ here\n"}
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/861386fb-5688-4a26-854e-e79d37954d17%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.