Executing blocks after failed

Hi,

I am not sure if this is the expected behaviour or it is a bug (I don’t even know if it happens to everybody), so before opening an issue I ask here.

In a playbook like this:

  • name: myname
    hosts: all
    gather_facts: True
    tasks:
  • block:
  • file: path=/tmp/file1 state=directory
  • file: path=/tmp/file3 state=directory
  • file: path=/tmp/file30 state=directory
    rescue:
  • file: path=/tmp/file2 state=directory
    any_errors_fatal: yes

If “/tmp/file1” creation fails, it will jump to the “file2” creation, not executing the creation of “file3” nor the one of “file30”.
This is how I would expect it to work, and it does.

Now. In a playbook like this:

  • name: myname
    hosts: all
    gather_facts: True
    tasks:
  • block:
  • block:
  • file: path=/tmp/file1 state=directory
  • file: path=/tmp/file3 state=directory
  • file: path=/tmp/file30 state=directory
    rescue:
  • file: path=/tmp/file2 state=directory
    any_errors_fatal: yes
  • block:
  • file: path=/tmp/file10 state=directory
    rescue:
  • file: path=/tmp/file20 state=directory
    any_errors_fatal: yes
    rescue:
  • debug: msg=“FAILED”

I would expect the same. So, if “file1” creation fails, neither “file3” nor “file30” are created. “file2” is created,… nice. BUT! “file10” is also created, so, the second block is executed and I would expect that it would not.

Do someone knows id it may be a bug and I should open an issue or if it is expected?

Thanks!

i would expect file 10 to be created unless file2 fails, as block/rescue ‘resets’ the errors to the result of the rescue block.

Thanks Brian,

This is exactly what is happening. I just understood the concept wrong!