After reading nested.py and realizing it would never do what I wanted,
I found a workaround.

On each ceph-ODSs :

- delegate_to: "{{ ceph-admin }}"
  shell: echo {{ inventory_hostname }}-{{ item }}
  with_items: disks



Anyway, thank you very much for your help :)


Le 13/12/11 14:53, Guillaume Subiron claviotta :
> 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. 
> 
> 
> Le 13/12/11 08:24, Michael DeHaan claviotta :
> > I think you probably want this:
> > 
> > - shell: echo {{ item.0 }}-{{item.1 }}
> >   with_together:
> >       - groups['ceph-OSDs']
> >       - disks
> > 
> > this will print for the first host
> > 
> > osd0-sdb
> > osd1-sdb
> > 
> > and for the second host
> > 
> > osd0-sdb
> > osd0-sdc
> > osd1-sdb
> > osd1-sdc
> > 
> > Let me know if that works for you and if I'm missing something we'll figure
> > it out.
> > 
> > Thanks!
> > 
> > 
> > 
> > 
> > 
> > On Wed, Dec 11, 2013 at 8:21 AM, Guillaume Subiron 
> > <[email protected]>wrote:
> > 
> > > Le 13/12/11 08:05, Michael DeHaan claviotta :
> > > > 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 :
> > >
> > > ceph_deploy osd prepare osd0:sda
> > > ceph_deploy osd prepare osd1:sda
> > > ceph_deploy osd prepare osd1:sdb
> > >
> > > > > > On 11 December 2013 09:53, Guillaume Subiron <[email protected]>
> > > > > wrote:
> > > > > >
> > > > > > > Hi,
> > > > > > >
> > > > > > > I'm trying to do a special kind of nesting loop, using the item of
> > > the
> > > > > > > first loop in the second loop:
> > > > > > >
> > > > > > > - name: Prepare OSDs
> > > > > > >   shell: ceph-deploy osd prepare {{ item[0] }}:{{ item[1] }}
> > > > > > >   with_nested:
> > > > > > >     - groups['ceph-ODSs']
> > > > > > >     - hostvars[item[0]]['disks']
> > > > > > >
> > > > > > > I'm not sure if this is possible, but I can't find any workaround.
> > > > > > >
> > >
> > > --
> > > Guillaume Subiron
> > >   Mail - [email protected]
> > >    GPG - C7C4 455C
> > > Jabber - [email protected]
> > >    IRC - maethor@(freenode|geeknode)
> > >
> > > --
> > > 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].
> > > For more options, visit https://groups.google.com/groups/opt_out.
> > >
> > 
> > 
> > 
> > -- 
> > Michael DeHaan <[email protected]>
> > CTO, AnsibleWorks, Inc.
> > http://www.ansibleworks.com/
> > 
> > -- 
> > 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].
> > For more options, visit https://groups.google.com/groups/opt_out.
> 
> -- 
> Guillaume Subiron 
>   Mail - [email protected]
>    GPG - C7C4 455C
> Jabber - [email protected]
>    IRC - maethor@(freenode|geeknode)
> 
> -- 
> 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].
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
Guillaume Subiron 
  Mail - [email protected]
   GPG - C7C4 455C
Jabber - [email protected]
   IRC - maethor@(freenode|geeknode)

-- 
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].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to