Which one is the recommended way, and why?

2016. július 7., csütörtök 13:59:15 UTC+2 időpontban Bence Takács a 
következőt írta:
>
> I think I messed up something :-)
> This way my examples are more easy to understand:
>
> === 1st scenario
>
>
> outside.yaml:
>
> ---
> - include: inside.yaml
>   vars:
>     my_outer_item: "{{ item }}"
>   with_items: 
>     - A
>     - B
>     - C
>  
>
> inside.yaml:
>
> ---
> - debug: msg="{{my_outer_item}} with {{ item }} is defined"
>   with_items:
>     - 1
>     - 2
>     - 3
>
>
>
> === 2nd scenario
>
>
> outside.yaml:
>
> ---
> - include: inside.yaml
>   with_items: 
>     - A
>     - B
>     - C
>
> inside.yaml:
>
> ---
> - set_fact
>   my_outer_item={{item}}
>
> - debug: msg="{{my_outer_item}} with {{ item }} is defined"
>   with_items:
>     - 1
>     - 2
>     - 3
>
>
> === 3rd Scenario:
>
> outside.yaml:
>
> ---
> - include: inside.yaml my_outer_item={{item}}
>   with_items: 
>     - A
>     - B
>     - C
>
> inside.yaml:
>
> ---
> - debug: msg="{{my_outer_item}} with {{ item }} is defined"
>   with_items:
>     - 1
>     - 2
>     - 3
>
>
> Sources:
>
> http://docs.ansible.com/ansible/playbooks_loops.html#loops-and-includes-in-2-0
>
> http://stackoverflow.com/questions/30785281/one-loop-over-multiple-ansible-tasks
> https://github.com/ansible/ansible/issues/14146
>
> But it would be good to get some clarification about the differences.
>
>
>
> 2016. július 7., csütörtök 10:04:03 UTC+2 időpontban Bence Takács a 
> következőt írta:
>>
>> What is the difference between the following syntaxes?
>>
>>
>> === 1st scenario
>>
>>
>> outside.yaml:
>>
>> ---
>> - include: inside.yaml
>>   vars:
>>     my_inner_item: "{{ item }}"
>>   with_items: 
>>     - A
>>     - B
>>     - C
>>  
>>
>> inside.yaml:
>>
>> ---
>> - debug: msg="{{my_inner_item}} with {{ item }} is defined"
>>   with_items:
>>     - 1
>>     - 2
>>     - 3
>>
>>
>>
>> === 2nd scenario
>>
>>
>> outside.yaml:
>>
>> ---
>> - include: inside.yaml
>>   with_items: 
>>     - A
>>     - B
>>     - C
>>
>> inside.yaml:
>>
>> ---
>> - set_fact
>>   my_inner_item={{item}}
>>
>> - debug: msg="{{my_inner_item}} with {{ item }} is defined"
>>   with_items:
>>     - 1
>>     - 2
>>     - 3
>>
>>
>> === 3rd Scenario:
>>
>> outside.yaml:
>>
>> ---
>> - include: inside.yaml my_inner_item={{item}}
>>   with_items: 
>>     - A
>>     - B
>>     - C
>>
>> inside.yaml:
>>
>> ---
>> - debug: msg="{{my_inner_item}} with {{ item }} is defined"
>>   with_items:
>>     - 1
>>     - 2
>>     - 3
>>
>>
>> ... I do not list the old "loop_control" scenario...
>>
>>
>> By the way: there is an existing issue connected to this topic:
>> https://github.com/ansible/ansible/issues/14146
>>
>

-- 
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/924ceee9-241a-46fa-b302-1cc63a31a0a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to