Yeah you are going to need to write your own iterator for a lookup plugin
at that level of complexity.

Take a look at "with_subelements" for one example of one that is almost
there.

Or you could just restructure your info to make it easier, if it was coming
from a YAML file.






On Fri, Aug 8, 2014 at 2:56 PM, <[email protected]> wrote:

> I have structures in group_vars files that looks roughly like the
> following:
>
> Accounts1:
>     files:
>         - { src: 'src_path/filename1', dest: 'dest_path/filename1' }
>         - { src: 'src_path/filename2', dest: 'dest_path/filename2' }
>     app_groups:
>         - { name: 'group1', gid: '1234' }
>         - { name: 'group2', gid: '1235' }
>         - { name: 'group3', gid: '1236' }
>     app_accounts:
>         - { name: 'account1', uid: '1234', home: '/home/account1',
> comment: 'account1' }
>         - { name: 'account2', uid: '1235', home: '/home/account2',
> comment: 'account3' }
>         - { name: 'account3', uid: '1236', home: '/home/account3',
> comment: 'account3' }
>
> Accounts2:
>     files:
>         - { src: 'src_path/filename3', dest: 'dest_path/filename3' }
>         - { src: 'src_path/filename4', dest: 'dest_path/filename4' }
>     app_groups:
>         - { name: 'group4', gid: '2234' }
>         - { name: 'group5', gid: '2235' }
>         - { name: 'group6', gid: '2236' }
>     app_accounts:
>         - { name: 'account4', uid: '2234', home: '/home/account1',
> comment: 'account4' }
>         - { name: 'account5', uid: '2235', home: '/home/account2',
> comment: 'account5' }
>         - { name: 'account6', uid: '2236', home: '/home/account3',
> comment: 'account6' }
>
> And then I have a list that looks like this:
>     Accounts: [ 'Accounts1', 'Accounts2' ]
>
> I want to be able to iterate over the Accounts list to refer to the
> members of the structures something like the following:
>
>     group: name="{{item.app_groups.name}}" gid="{{item.app_groups.gid}}"
>     with_items: Accounts
>
> It isn't quite working.  What I am finding is that 'item' in the group
> task is being populated with the strings "Accounts1" and "Accounts2", but
> what I really want in 'item' is the objects named Accounts1 and Accounts2.
> So is there some way make 'item' be a reference to an object instead of an
> object itself?  I have tried 'with_item', 'with_nested', and 'with_dict',
> all to no avail.
>     Thanks,
>     -Mark
>
> --
> 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/cc6a6c33-597a-404b-a202-7439034edd3d%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/cc6a6c33-597a-404b-a202-7439034edd3d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CA%2BnsWgzVO5hN3RcYhS%2BOXD%3D%2Bj8a5-CxP-uAfFUssXFTXt43%2BBQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to