skipped tasks are executed! In Ansible.
Just want to let you know.
This example is bizarre:
- name: Try /usr
command: /usr/bin/foo
when: foo_usr
register: foo_output
- name: Try /usr/local
command: /usr/local/bin/foo
when: foo_usr_bin
register: foo_output
- debug: var=foo_output
Guess what’s gonna happen if you set foo_usr
to true
and foo_usr_bin
to false
?
"foo_output": {
"changed": false,
"skip_reason": "Conditional result was False",
"skipped": true
}
Yep, register will overwrite old register even if task is ‘skipped’. Skips are, actually, executed. They are not replacement of the normal branching (which maddeningly hard in Ansible).
After few attempts to write something stable in Ansible I found myself in a Quick Basic limbo. They do everything they can to make Ansible NOT_A_PROGRAMMING_LANGUAGE. In practice that means, that complications in your playbook are concentrated faster than complexity.
The more logic you have in playbook or role, the worse results become, the more shady corners are waiting you with WTF unexpected quirk in logic.
I’m getting tired of Ansible. Really, really tired. The reason is that it’s impossible to keep whole complicated set of rules for Ansible ‘language’ in head. It’s like a rulebook with contradicting chapters and exceptions longer than rules itself.