Excerpts from Rik Theys's message of 2013-05-17 09:20:26 -0400:
> Hi,
>
> I'm creating a playbook in which I register a variable to hold the virt
> info output:
>
> - name: build info on guests
> action: virt command=info
> register: vminfo
>
> In a followup task I want to add running guests to a group:
>
> - name: add running guests to new group
> action: add_host hostname=${item} groupname=running_vms
> with_items: $vminfo
> only_if: "'${item.status}' == 'running'"
>
> This fails because with_items expects a list and I'm providing a dictionary.
>
> Is there a way to make with_items use the keys of the dictionary as list
> items?
I know this works in normal jinja2 templates:
'{{ item.keys() }}'
So that might work in Ansible 1.2 (devel from git).
If you need something more complicated, you could always write a filter
plugins, which I'm fairly sure works with the jinja-style substitutions.
--
C. Morgan Hamill
<
cha...@wesleyan.edu>