Ummm, I'm not entirely sure what you want to do but you can easily use a
dict to set the variables...
hostlist:
- { hostname: 'name1', item1: 'value1A'. item2: 'value1B' }
- { hostname: 'name2', item1: 'value2A'. item2: 'value2B' }
Then you have {{ item.hostname }}. {{ item.item1 }} and {{ item.item2 }}
Does this help?
On Thursday, March 6, 2014 1:52:16 PM UTC-8, Brad Egan wrote:
>
> Hi,
>
> New to Ansible and probably not using it the way most are. I'm a network
> engineer and am trying to use it to generate config files using the
> template module. It's working well for one file but I'd like to extend it
> to support multiple "hosts" that use different variables.
>
> In my hosts file, I only have localhost defined (since I'm just writing
> data to files). I have a role "switch" that includes one task using
> with_items set to "hostname: item1" etc. I am wondering if you can specify
> a vars_files for each of the "items"? I tried to set vars_files in the
> playbook site.yml to "vars/roles/switch/vars/{{item.hostname}}.yml" but
> that doesn't work. I think I could "trick" Ansible by defining multiple
> hosts to resolve to 127.0.0.1 in the hosts file but would rather avoid
> that. Any suggestions?
>
--
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/ab6e890b-08de-40e1-95ed-e03d231b60ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.