I\'m trying to enclose tasks in the block with some when condition. Also some tasks inside this block have additional conditions. The problem is such tasks (with additional cond
You should fix the indentation of the when
declarations.
Maybe it's not just possible in Ansible 2.4 to have enclosed tasks with additional conditions?
Ansible 2.4 works ok:
tasks:
- block:
- debug:
msg: "task 1"
- debug:
msg: "task 2"
when: false
- debug:
msg: "task 3"
when: true
when: true
results in:
TASK [debug] **************************************************************************************************
ok: [localhost] => {
"msg": "task 1"
}
TASK [debug] **************************************************************************************************
skipping: [localhost]
TASK [debug] **************************************************************************************************
ok: [localhost] => {
"msg": "task 3"
}
And you can always reorder the keys in block
task for clarity:
tasks:
- when: true
block:
- debug: