Hello,

Sorry to insist here I thinks I understand the whole concept of nested 
loops ;-)

A nested loop over *one* item satisfies my sensibilities because, in this 
specific case, I feel it plays the same role as "0 for the addition" or "1 
for the multiplication".

3 list case :
Loop
  Loop
    Loop

2 list case:
Loop
  Loop

1 list case:
Loop

It doesn't seem mis-behaved to be. 

The main reason I am insisting here is because with_items and with_nested 
lead to totally different referencing schemes for the items.

with_items:  {{ item }}
with_nested: {{ item.0 }}

which creates, in my viewpoint, non-necessary burden when you need to jump 
from a with_items scenario to a with_nested scenario and refactor a role.

Is there a way to do a with_items and still get the items as {{ item.0 }} ? 
maybe there is something I missed.

Thanks




Le lundi 24 février 2014 14:07:47 UTC+1, Michael DeHaan a écrit :
>
> with_nested is intended to be iteration over two loops, a nested loop.
>
> with_nested over a single list doesn't seem to make sense for me, you 
> would just use "with_items".
>
> A nested loop over *one* list offends my computer science sensibilities, 
> and may also indicate a typo from the user, I don't think it should "just 
> attempt to do something else" here.
>
>
>
>
> On Mon, Feb 24, 2014 at 5:01 AM, Jerome Wagner <[email protected]<javascript:>
> > wrote:
>
>> Hello,
>>
>> I don't know if this is normal (feature?) or if it can be considered as a 
>> bug that needs to be fixed :
>>
>> - name: my task
>>   action: ...
>>   with_nested:
>>     - myList
>>
>> does not loop over myList with each item referenced as item.0
>>
>> I always have to go the "with_items: myList" and this breaks my workflow 
>> because 
>>  * when a task starts needing a nested loop all the item references need 
>> to be changed (from item to item.0 for instance).
>>  * I cannot copy/paste references between tasks using with_items and 
>> tasks using with_nested.
>>
>> I can always write 
>>
>> - name: my task
>>   action: ...
>>   with_nested:
>>     - myList
>>     - [ "" ]
>>
>> but it feels clunky.
>>
>> Has any of you encountered the same problem ?
>>
>>
>>
>>  -- 
>> 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] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/a3a7f704-24c4-4c5d-8af3-256716985036%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
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/b88a90d4-a736-40c5-8d56-ae52c88a8f92%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to