Le 13/12/11 11:18, Serge van Ginderachter claviotta :
Have a look at the with_subelements lookup plugin.
I know very well with_subelements, but in this case I'm not trying to
access a subelement in the first element, I'm trying to use the first
element to access an entry in an other dictionary.
I don't think with_subelements is well suited to this case. Do you
have an example ?
Before we dive into a technical solution let me understand your use case
and what you are modelling a bit better.
So groups['ceph-ODSs'] would be all machines in the ceph-ODSs group.
That's right.
I'd probably just define a variable like "disks" on the group, but I'm
unclear why that wouldn't work in your case.
I could probably understand more if I could see how "disks" differs between
hosts.
It's simple, my Ceph OSD (storage nodes) are all différents. Some
contains 2 hard drives (sdb, sdc), some contains 10 (sdb, sdc, sdd…).
"disks" is a list of hard drives, which is different from one host to
another. ex:
inventory
osd0
osd1
[ceph-OSDs]
osd0
osd1
host_vars/osd0
disks:
- sdb
host_vars/osd1
disks:
- sdb
- sdc
In my nested loop, I need to loop over the Ceph Storage nodes and
their hard drive. The hard drive list is an host variable (accessible
by hostvars[osd0]['disks'], for instance).
With the example above, I want my playbook to do :
Hum, this is not what I'm looking for, because my action is not
executed on the ceph-OSDs, but on another host (a centralized admin
node).
In this playbook, I'm not doing anything on the ceph-OSDs.
What I need to do (only on my admin node) is :
- shell: echo {{ item.0 }}-{{ item.1 }}
with_nested:
- groups['ceph-OSDs']
- the disks of the current item in the "groups['ceph-OSDs']" loop
I want it to print (on the admin host) :
osd0-sdb
osd1-sdb
osd1-sdc
Do you understand the problem ? I don't see any workaround. This is a
matter of syntax.
I am also having the same issue with nested loops .
my scenario is nothing but th__e matrix multiplication of n*n__
Can some one please suggest how to implement it using ansible loops along with adding conidition of count ++ and count –