So only_if is pretty flexible and it will stay around. We'll need it.
However I've never really been comfortable with asking people to write
Python expressions in a language that intentionally seeks to AVOID
such expressions.
This small corner of ansible is asking folks to understand a
programming language we obviously want to hide.
As such, I think "easy conditionals" becomes an interesting mini-theme
for the 0.9 release.
Tentative syntax follows.
Imagine if you could do things without Python or quoting:
- action: ...
when_defined: foo
when_defined: some.var.foo
when_equal: command.rc 1
when_successful: command_register_result
when_failed: command_register_result
when_greater_than: some.var.foo 12
when_all_of:
- equal: result 0
- find: some_command.stdout some_string
when_one_of:
- equal: result.rc 0
- equal: result2.rc 1
And, like before, you should be able to save 'when' tests in vars, like so:
when: $is_rhel6
Internally, these would compile down to only_if expressions, but would
not require writing Python, quoting, or remembering what data types to
cast things to. As a result, we keep conditional logic
simple, and make things easier to read.
--Michael