It seems like you're going to need another type of iterator (lookup plugin)
that doesn't exist to traverse these, akin to something like a
with_dict_items or something.

I don't know your use cases, but another option might be to just make the
"data" and "fra" stuff a element inside the hash.

  - name: Blerg
    shell: "Use {{ item.disk }}  and set label={{ item.label }} "
    with_items: storage_config
    when: item.category in [ 'fra', 'crs', 'data' ]

etc?


On Mon, Jul 7, 2014 at 3:20 PM, <stibbons.pe...@gmail.com> wrote:

> Hi,
> I'm kind of new to Ansible and I haven't really gotten the terminology
> down yet, so I hope you'd bear with me.
>
> I've got a task which loops through a bunch of disks and performs a set of
> operations on them. The placeholders/keys (CRS,DATA,FRA) are names on a
> sort of logical volumes which should use the disks listed under them.
> The construct is loaded via group_vars or host_vars and looks like this:
> ---
>        crs:
>          - {disk: /dev/sdc, label: CRS01}
>          - {disk: /dev/sdd, label: CRS02}
>        data:
>          - {disk: /dev/sdd, label: DATA01}
>          - {disk: /dev/sde, label: DATA02}
>        fra:
>          - {disk: /dev/sdg, label: FRA01}
>          - {disk: /dev/sdh, label: FRA02}
>          - {disk: /dev/sdi, label: FRA03}
>
> The task that uses it accesses it like so:
>
>   - name: Blerg
>     shell: "Use {{ item.disk }}  and set label={{ item.label }} "
>     with_items:
>        - "{{ crs }}"
>        - "{{ data }}"
>        - "{{ fra }}"
>
>
> This works fine but I really dont like to have the names (CRS etc) in the
> loop as they potentially could be called anything.
>
> So what I would like to be able to do is to have something like this, and
> just call 'storage_layout' with a "with_something" so I dont have to
> hard-code the volume-names.
>
>     storage_layout:
>         crs:
>           - {disk: /dev/sdc, label: CRS01}
>           - {disk: /dev/sdd, label: CRS02}
>         data:
>           - {disk: /dev/sde, label: DATA01}
>           - {disk: /dev/sdf, label: DATA02}
>         fra:
>           - {disk: /dev/sdg, label: FRA01}
>           - {disk: /dev/sdh, label: FRA02}
>           - {disk: /dev/sdi, label: FRA03}
>
>
> Is this even possible, and what would it potentially look like?
>
> I've tried with 'with_dict' but that seems to only accept 1 entry/key,
> like this.
>
>     storage_layout:
>         crs:
>            {disk: /dev/sdc, label: CRS01}
>         data:
>            {disk: /dev/sde, label: DATA01}
>         fra:
>            {disk: /dev/sdg, label: FRA01}
>
>
>
> Thanks!
> /Peter
>
>
>  --
> 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/5744820d-dccd-4045-b60f-7fdab8287087%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/5744820d-dccd-4045-b60f-7fdab8287087%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 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/CA%2BnsWgx8YR6zoN4JCxV0iYo64xHgDbMBQtaCdCPo1bUA%3DDKjCQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to