On 01. des. 2016 14:31, sergio.guil...@mojix.com wrote:
Hi, I created a role that has a rescue block where role is marked as failed:
--- #myrole
- block:
...
rescue:
- fail: msg='some message' #mark as fail ansible_failed_task is defined
When ever Ansible run the fail module, it will immediately stop, no
other task will be executed for that host.
On my playbook the idea is to send notification if ansible_failed_task is
defined that's why "myrole" fails on rescue section. So on my playbook if
that variable is defined I send a notification:
- hosts: automation
gather_facts: True
post_tasks:
- include: notification.yml status=unstable action="Tests unstable"
when: ansible_failed_task is defined
roles:
- { role: myrole, tags: tests}
When I run this playbook and "myrole" fails post_tasks section is never
executed, so my question is that: Will post_tasks execute no matter whether
role has failed or not? if not what should I use so post_tasks get executed
no matter role's result?
The post_tasks is just a way of group tasks to be run at some sequence.
In a play you can have the following and they will run in the order they
are listed bellow
1. pre_tasks
2. roles
3. tasks
4. post_tasks
In your example when it hits fail: it will stop an no more task will be
executed.
So the rest of the roles section, tasks and post_tasks will not run for
that host.
--
Kai Stian Olstad
--
You received this message because you are subscribed to the Google Groups "Ansible
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/7538d3d4-a518-b117-e09b-9e5fb67db568%40olstad.com.
For more options, visit https://groups.google.com/d/optout.