Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible - how to use when with an or operator

Tags:

ansible

My goal is to use a conditional check, on two variables, using the or operator. There are two vars:

var1: test
var2: another

Using one a check on one variable works.

  when: "'te' in var1" # works!

But using two variables is always true.

  when: "'te' in var1 or var2" # True
  when: "'xxx' in var1 or var2" # Also true, but I expect false
  when: "'xxx' in var1" or "'xxx' in var2" # syntax error

What am I doing wrong?

like image 587
Kevin C Avatar asked Dec 02 '16 11:12

Kevin C


1 Answers

Got it.

      when: "'xxx' in var1 or 'te' in var2" # works
like image 127
Kevin C Avatar answered Oct 15 '22 07:10

Kevin C