Michael,
Your conditionals_part2.yml contains this example line:
only_if: ‘not ($is_favcolor_blue)’
Since you do not allow binary operators in the value of only_if, it seems odd that you allow the unary operator. Personally, I would not find
only_if: ‘“$var” == “constant”’
hard to read. But if you are going to disallow that construct then I suggest you also disallow the unary “not” operator and instead use this construct:
only_if_not: ‘$is_favcolor_blue’
As I said, though, I would be happy if I could put an expression instead of just a variable in the value of only_if.
Cheers,
– Art Z.
Michael,
Your conditionals_part2.yml contains this example line:
only_if: ‘not ($is_favcolor_blue)’
Since you do not allow binary operators in the value of only_if, it seems odd that you allow the unary operator. Personally, I would not find
only_if: ‘“$var” == “constant”’
I don’t allow or disallow anything, it’s a Python expression. Where does it say that?
As I said, though, I would be happy if I could put an expression instead of just a variable in the value of only_if.
I’m confused by this, they are expressions.
Michael,
Your conditionals_part2.yml contains this example line:
only_if: ‘not ($is_favcolor_blue)’
Since you do not allow binary operators in the value of only_if, it seems odd that you allow the unary operator. Personally, I would not find
only_if: ‘“$var” == “constant”’
I don’t allow or disallow anything, it’s a Python expression. Where does it say that?
As I said, though, I would be happy if I could put an expression instead of just a variable in the value of only_if.
I’m confused by this, they are expressions.
Michael,
I guess I misunderstood this comment:
Not only can we assign variables for reuse, but we can also assign conditional
expressions. By keeping these in ‘vars’, the task section remains
extraordinarily clean, and not littered with programming language
constructs – so it’s easily skimmed by humans.
as meaning that ansible required the only_if argument to be a single variable.
– Art Z.
as meaning that ansible required the only_if argument to be a single variable.
It can either be a string Python expression or something that evaluates to a string Python expression.