post_tasks did not run for all hosts after 1 host failed block in role

18 views
Skip to first unread message

Daniel Leonard

unread,
Nov 28, 2017, 10:12:03 PM11/28/17
to Ansible Project
Hi guys,

Ran a playbook against 2 hosts: host1 and host2

Extract of playbook:

roles:
   - role: a
   - role: b
   - role: c
post_tasks:
   - name: Post Task 1
   ::::::::::::::::::::::::::
   - name: Post Task 2
   ::::::::::::::::::::::::::
   - name: Post Task 3
   ::::::::::::::::::::::::::

In role c the main task is like:

---
- block:
   - include: x.yml
   - include: y.yml
   - include: z.yml
  rescue:
   - fail: msg="There was a failure in main!!"


y.yml is like:

---
- block:
   - name: Task 1
   ::::::::::::::::::::::::::
   - name: Task 2
   ::::::::::::::::::::::::::
   - name: Task 3
   ::::::::::::::::::::::::::
  rescue:
   - fail: msg="There was a failure in y!!"


host2 failed a task in y.yml. As expected all other tasks in z.yml were executed for host1

However, neither host1 or host2 executed any of the post tasks. I did not expect this to be the behavior. I thought host1 should execute the post tasks.

Could anybody please help me to understand why this happens and suggest how to make sure the post_tasks execute for hosts which have not had any role task failures?
Preferably while still using post_tasks. 

Thanks a lot,
Daniel

Daniel Leonard

unread,
Nov 30, 2017, 7:04:02 PM11/30/17
to Ansible Project
Hi,

Actually I'm only getting this behavior when using the ansible integration for StackStorm https://github.com/StackStorm-Exchange/stackstorm-ansible

Running this playbook using plain ansible behaves as I expected it would i.e. host1 executes post_tasks.

Cheers,
Daniel
Reply all
Reply to author
Forward
0 new messages