On Tuesday, December 15, 2015 at 7:01:04 AM UTC-8, Mike Biancaniello wrote:
>
> Will this do what you need?  using structure[list] instead of trying to 
> nest.
>
> ---
> - name: stuff
>   connection: local
>   gather_facts: no
>   hosts: localhost
>
>   vars:
>     list: list1
>     structure:
>       list1:
>         - {var1: "val1", var2: "val2", var3: "val3"}
>       list2:
>         - {var1: "val1", var2: "val2", var3: "val3"}
>       list3:
>         - {var1: "val1", var2: "val2", var3: "val3"}
>
>
>   tasks:
>   - name: with_index
>     debug: msg="var1={{item.var1}}, var2={{item.var2}}, 
> var3={{item.var3}}"
>     with_items:
>       - "{{structure[list]}}"
>
>  
That is close but not quite what I am looking for.  I oversimplified my 
description of the problem.  I should have said "I need to select one or 
more of those dictionaries with keys".  So 'list' is a list of one or more 
keys:
    list:
      - list1
      - list2

And that is where this got complicated.  The temptation is to do something 
like this:

    - debug: msg="var1={{STRUCTURE.{{item}}.val1}}, 
var2={{STRUCTURE.{{item}}.val2}}, var3={{STRUCTURE.{{item}}.val3}}"
      with_items:
        - "{{list}}"
 
Of course, I can't have nested braces, but your example gave me the clue I 
needed to make this work.  Following your lead I came up with this:

    - debug: msg="var1={{STRUCTURE[item].0.val1}}, 
var2={{STRUCTURE[item].0.val2}}, var3={{STRUCTURE[item].0.val3}}"
      with_items:
        - "{{list}}"

And that got me what I needed!
Thanks for your help!
-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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3debc7c0-bc96-4c4d-8d81-6cf822f94dbb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to