On 12/11/19 6:50 PM, Rahul Kumar wrote:
> 
> Ok it will skip and will continue to next item. Right ? 

Yes

Regards
          Racke

> 
> On Wed, 11 Dec 2019 at 11:12 PM, Stefan Hornburg (Racke) <[email protected] 
> <mailto:[email protected]>> wrote:
> 
>     On 12/11/19 6:39 PM, Rahul Kumar wrote:
>     >
>     > Thanks vlado! What will happen if let’s say item2conf is not defined ?
>     >
> 
>     It will skip it.
> 
>     Regards
>               Racke
> 
>     > On Wed, 11 Dec 2019 at 9:47 PM, Vladimir Botka <[email protected] 
> <mailto:[email protected]>
>     <mailto:[email protected] <mailto:[email protected]>>> wrote:
>     >
>     >     Hi Rahul,
>     >
>     >     On Wed, 11 Dec 2019 20:03:32 +0530
>     >     Rahul Kumar <[email protected] <mailto:[email protected]> 
> <mailto:[email protected]
>     <mailto:[email protected]>>> wrote:
>     >
>     >     > Hi Ansible Gurus,
>     >     > How can I optimize below code ? below is the sufficient code to 
> understand
>     >     > the problem...
>     >     >
>     >     > - name:  Application item1Conf provisioning
>     >     >   include_tasks: resturlcall.yml
>     >     >   with_items:
>     >     >     - { name: '{{item1Conf}}', resource: 'item1' }
>     >     >   when: item1Conf is defined
>     >     >
>     >     > - name: Application item2Conf provisioning
>     >     >   include_tasks: resturlcall.yml
>     >     >   with_items:
>     >     >     - { name: '{{item2Conf}}', resource: 'item2' }
>     >     >   when: item2Conf is defined
>     >     >
>     >     > - name: Application item3Conf provisioning
>     >     >   include_tasks: resturlcall.yml
>     >     >   with_items:
>     >     >     - { name: '{{item3Conf}}', resource: 'item3' }
>     >     >   when: item3Conf is defined
>     >
>     >     Default filter is needed to loop all items in one task because 
> *item* is
>     >     evaluated before *when*. Empty variable evaluates to False. For 
> example
>     >
>     >      - name:  Application provisioning
>     >        include_tasks: resturlcall.yml
>     >        loop:
>     >          - {name: '{{ item1Conf|default() }}', resource: 'item1'}
>     >          - {name: '{{ item2Conf|default() }}', resource: 'item2'}
>     >          - {name: '{{ item3Conf|default() }}', resource: 'item3'}
>     >        when: item.name <http://item.name> <http://item.name>
>     >
>     >     Cheers,
>     >
>     >             -vlado
>     >
>     > --
>     > 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] 
> <mailto:ansible-project%[email protected]>
>     <mailto:[email protected] 
> <mailto:ansible-project%[email protected]>>.
>     > To view this discussion on the web visit
>     >
>     
> https://groups.google.com/d/msgid/ansible-project/CAGH8rEzmM2QzxTqkj7mG2YaUuAVZ2dwWfQRLcxs%2BZ-hEFObvgA%40mail.gmail.com
>     >
>     
> <https://groups.google.com/d/msgid/ansible-project/CAGH8rEzmM2QzxTqkj7mG2YaUuAVZ2dwWfQRLcxs%2BZ-hEFObvgA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> 
> 
>     -- 
>     Ecommerce and Linux consulting + Perl and web application programming.
>     Debian and Sympa administration. Provisioning with Ansible.
> 
>     -- 
>     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] 
> <mailto:ansible-project%[email protected]>.
>     To view this discussion on the web visit
>     
> https://groups.google.com/d/msgid/ansible-project/3c923738-3af7-ebc3-e9fd-9399ad658127%40linuxia.de.
> 
> -- 
> 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] 
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAGH8rExy_qL8QbT5BdUYVQKCUYvAVWK3rJeUgB0GWeht2N%3DHpQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAGH8rExy_qL8QbT5BdUYVQKCUYvAVWK3rJeUgB0GWeht2N%3DHpQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.


-- 
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8556391e-3eb6-cfc3-1971-23fa60fd2199%40linuxia.de.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to