i think what you need is with_dict: object and use it via item.key and item.value
On Fri, Jun 5, 2015 at 11:32 AM, Naween Ghimire <[email protected]> wrote: > Hi I have been trying to access all the sub-elements available in a map > but i am unable to do so: > > Here's my usecase: > > A yaml map is defined as follows: > > object: > element1: "value1" > element2: "value2" > element3: "value3" > ... > ... > ... > elementn: "valuen" > > In a task i need to access all the values (value1,value2,value3,...,valuen) > > I tried the following: > > - name: pass values to script > debug: "msg={{ item }}" > with_items: > - "{{ object }}" > > But this doesn't seem to work. > > Whereas the following works, > > - name: pass values to script > debug: "msg={{ item }}" > with_items: > - "{{ object.element1 }}" > - "{{ object.element2 }}" > > But this is not scalable, and i have a usecase where the number of > elements might vary. Is there a way to get this done in ansible ? > > > Regards, > Naween > > -- > 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/da9e4739-eefa-4975-adc3-65ad0b6a3610%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/da9e4739-eefa-4975-adc3-65ad0b6a3610%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/CAFUV_d4exJo78TUEyeJy0V9nhKjYZ5G_EbsS9C%3DrqHo-78P_BQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
