ansible block not running as expected

I have ansible 2.2.1.0 and I have this role:

- block:
    - shell: echo 1
    - shell: fail
    - shell: echo 2
  rescue:
    - shell: echo 3
  always:
    - shell: echo 4

- name: running something after the block
  shell: echo 5
 

If I run this role, the first part of the block fails because of the “fail” command (which does not exist :slight_smile: “stderr: /bin/sh: 1: fail: not found”) so the rescue kicks + always. But the last task, the one “running something after the block” never runs. The play finises!

Why is that ? The expected result I would see it as: if the first part of the block fails rescue kicks in + always (if any) and then continues the play run with the rest of the tasks.

In the documentation there is nothing about this.

Is there a workaround this ?

I can't confirm this with 2.2.1.0

Because I said it’s a role and you put them as tasks :wink:

Sorry about that, I didn't think it would matter, but it does.
Testet the tasks in a role and it stopped as you say.

Testet Ansible 2.1.4.0 and 2.2.0.0 and there it works as expected, so this bug/behaviour was introduced in 2.2.1.0.

That is correct. We ran into this last week as well. Found the bug here… https://github.com/ansible/ansible/issues/20736

Best,
/jhd

++ Just we began running 2.2.3.0 and we’re seeing this same behavior.