Michael DeHaan <[email protected]> writes:
> You can definitely pass in with_items with a list of hashes.
>
> module_name: foo={{ item.name }} bar={{ item.value }}
> with_items:
> - { name: 'x', value: 'y' }
> - { name: 'a', value: 'b' }
>
> etc
>
> or with_items: alist_of_hashes
>
> etc
>
> or as you have it, with
>
> with_items: [ { name: 'x', value: 'y' }, { name: 'a', value: 'b' } ]
>
> It seems like in your question instead of
>
> zfs: {{ item }}
>
> you might need to pass something more specific?
>
> zfs: {{ item.zfs }}
>
> ??
>
> am I misunderstanding the question ?
Maybe or, more probably, I can’t explain myself. :)
Starting from your example, let’s add an attribute only in the second item:
module_name: foo={{ item.name }} bar={{ item.value }}
with_items:
- { name: 'x', value: 'y' }
- { name: 'a', value: 'b', extra: 'xtr' }
How should deal with it? Is adding
{{ 'extra=%s' % item.extra if item.extra is defined else '' }}
the preferred way?
Now let’s say that `extra` is a map:
module_name: foo={{ item.name }} bar={{ item.value }}
with_items:
- { name: 'x', value: 'y' }
- { name: 'a', value: 'b', extra: {k: 'v'} }
If I use the `defined` check shown above the module gets a string, I
believe.
I hope I didn’t mess up too much my argument :)
--
Giorgio Valoti
--
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].
For more options, visit https://groups.google.com/groups/opt_out.