I'm trying to do something complex with variables that allows me to
auto-generate kickstart files for the VMs in my inventory. It almost works
but I'm getting an odd error. The variables are spread across multiple
files so here is an example:
group_vars/all
prod_vlan12_network_gateway: 192.168.12.1
host_vars/host.domain.com
default_gateway: "{{ prod_vlan12_network_gateway }}"
(The host variable references the global one, DRY style.)
role/kickstart
I have a template in this role that references the host variable like this:
{{ hostvars[item]['default_gateway'] }}
where item comes from a: "with_items: groups['vms']" statement in the
role's task file
The overall pattern works fine except in this case where the host variable
references a global one. In this case the template output is, "{{
prod_vlan12_network_gateway }}" rather than the expected "192.168.12.1". In
cases where the host variable is defined directly, e.g. "vcpus: 2", it
works fine.
I do this to avoid repeating data like the gateway IP address multiple
times. Is there a Jinja trick or something else I can try to get it resolve
these nested variables?
Thanks,
Aaron
--
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/a8c64ccd-7c3c-4951-bba9-1ceb6067fcf8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.