Re: [ansible-project] When condition 'or' structure question

2019-09-10 Thread Vladimir Botka
On Tue, 10 Sep 2019 21:16:04 +0200
Kai Stian Olstad  wrote:

> On 10.09.2019 20:14, Vladimir Botka wrote:
> > On Tue, 10 Sep 2019 10:45:45 -0700
> > Guy Knights  wrote:
> >   
> >> It's possible to define a series of 'and' conditions for a task as follows:
> >>
> >>when:
> >>  - foo == true
> >>  - bar == true
> >>
> >> As far as I'm aware, the only way to define 'or' conditions is in-line, as
> >> such:
> >>
> >>when: foo == true or bar == true
> >>
> >> Is there any other way to define 'or' conditions, in a way that's similar
> >> to the first example?  
> > 
> > No. It is not. It can be simplified
> > 
> > when:
> >   - foo
> >   - bar
> > 
> > when: foo or bar  
> 
> You can also do
> 
>   when: true in [foo, bar]

And

when: [foo, bar] is all

when: [foo, bar] is any

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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20190910225415.582c193b%40gmail.com.


pgp7MuShybqhq.pgp
Description: OpenPGP digital signature


Re: [ansible-project] When condition 'or' structure question

2019-09-10 Thread Kai Stian Olstad
On 10.09.2019 20:14, Vladimir Botka wrote:
> On Tue, 10 Sep 2019 10:45:45 -0700
> Guy Knights  wrote:
> 
>> It's possible to define a series of 'and' conditions for a task as follows:
>>
>>when:
>>  - foo == true
>>  - bar == true
>>
>> As far as I'm aware, the only way to define 'or' conditions is in-line, as
>> such:
>>
>>when: foo == true or bar == true
>>
>> Is there any other way to define 'or' conditions, in a way that's similar
>> to the first example?
> 
> No. It is not. It can be simplified
> 
> when:
>   - foo
>   - bar
> 
> when: foo or bar

You can also do

  when: true in [foo, bar]


-- 
Kai Stian Olstad

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/04e502c1-a208-92c0-bd7d-6c4cb85c22a3%40olstad.com.


Re: [ansible-project] When condition 'or' structure question

2019-09-10 Thread Vladimir Botka
On Tue, 10 Sep 2019 10:45:45 -0700
Guy Knights  wrote:

> It's possible to define a series of 'and' conditions for a task as follows:
> 
>   when:
> - foo == true
> - bar == true
> 
> As far as I'm aware, the only way to define 'or' conditions is in-line, as
> such:
> 
>   when: foo == true or bar == true
> 
> Is there any other way to define 'or' conditions, in a way that's similar
> to the first example?

No. It is not. It can be simplified

   when:
 - foo
 - bar

   when: foo or bar

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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20190910201421.54fdcdbf%40gmail.com.


pgpNoGjoTa0WO.pgp
Description: OpenPGP digital signature


[ansible-project] When condition 'or' structure question

2019-09-10 Thread Guy Knights
It's possible to define a series of 'and' conditions for a task as follows:

  when:
- foo == true
- bar == true

As far as I'm aware, the only way to define 'or' conditions is in-line, as
such:

  when: foo == true or bar == true

Is there any other way to define 'or' conditions, in a way that's similar
to the first example?

Thanks,
Guy

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAFtmDk-v-71wn-10_TfmbDyHdSk7CdPaMa-91V2uxsV4ASPurg%40mail.gmail.com.