ansible didn't stop execution upon a task failure

95 views
Skip to first unread message

Leon Xie

unread,
Nov 30, 2015, 3:11:11 AM11/30/15
to Ansible Project
hi

I have the below ansible playbook named backup_data.yml, which is included by the main playbook named upgrade.yml.

backup_data.yml
++++++++++++++++++++++++++++++++++++++++++++++++++++++
---
- name: backup data
  hosts: allvm
  remote_user: root
  max_fail_percentage: 0
  any_errors_fatal: True
  roles:
    - backup_data
  tags: backup_data

- name: check previous task result
  hosts: allvm
  max_fail_percentage: 0
  any_errors_fatal: True
  remote_user: root
  tasks:
    - command: 'true'
++++++++++++++++++++++++++++++++++++++++++++++++++++++

upgrade.yml
++++++++++++++++++++++++++++++++++++++++++++++++++++++
---
- include: backup_data.yml
- include: prepare_vms.yml
++++++++++++++++++++++++++++++++++++++++++++++++++++++

prepare_vms.yml
++++++++++++++++++++++++++++++++++++++++++++++++++++++
---
- name: prepare data for virtual machines
  hosts: localhost
  max_fail_percentage: 0
  roles:
    - prepare_vms
++++++++++++++++++++++++++++++++++++++++++++++++++++++

what I expect is that when any task in backup_data.yml fails, ansible stops execution
however, I got the below result:
++++++++++++++++++++++++++++++++++++++++++++++++++++++
2015-11-24 16:06:04,175 p=22112 u=root |  TASK: [backup_data | backup data] *********************************************
2015-11-24 16:06:07,152 p=22112 u=root |  changed: [192.168.0.42]
2015-11-24 16:06:32,556 p=22112 u=root |  changed: [192.168.0.43]
2015-11-24 16:06:45,348 p=22112 u=root |  failed: [192.168.0.41] => {"changed": true, "cmd": ["backup.pl", "-f", "backup.bak", "-noask"], "delta": "0:00:40.590445", "end": "2015-11-24 16:06:43.102890", "rc": 1, "start": "2015-11-24 16:06:02.512445", "warnings": []}
2015-11-24 16:06:45,367 p=22112 u=root |  PLAY [check previous task result] *********************************************
2015-11-24 16:06:45,368 p=22112 u=root |  TASK: [command true] **********************************************************
2015-11-24 16:06:45,988 p=22112 u=root |  changed: [192.168.0.43]
2015-11-24 16:06:46,002 p=22112 u=root |  changed: [192.168.0.42]
2015-11-24 16:06:46,014 p=22112 u=root |  PLAY [prepare data for virtual machines] **************************************
2015-11-24 16:06:46,015 p=22112 u=root |  TASK: [prepare_vms | create data directory] ***********
2015-11-24 16:06:46,302 p=22112 u=root |  changed: [localhost]
++++++++++++++++++++++++++++++++++++++++++++++++++++++

will somebody point me to the right direction? thanks a lot in advance.

Leon Xie

unread,
Nov 30, 2015, 3:17:00 AM11/30/15
to Ansible Project
ansible version is as below:


#ansible --version
 [WARNING]: The version of gmp you have installed has a known issue regarding
timing vulnerabilities when used with pycrypto. If possible, you should update
it (i.e. yum update gmp).

ansible 1.9.0.1
  configured module search path = None

Brian Coca

unread,
Nov 30, 2015, 6:02:08 PM11/30/15
to Ansible Project
only host 192.168.0.41 failed the task, hosts .42 and .43 continue the
play, the play would abort if all hosts failed.
> --
> 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-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/56e271ae-c326-4c34-89ac-1911b20b4020%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Brian Coca

Leon Xie

unread,
Nov 30, 2015, 8:47:06 PM11/30/15
to Ansible Project
Hi Brian,

Is there any way to abort 42 and 43 host if any task fails on 41 host?
As I know, "any_errors_fatal: True" and " max_fail_percentage: 0' can be used to archive this, however, it didn't work.

thank


On Tuesday, December 1, 2015 at 7:02:08 AM UTC+8, Brian Coca wrote:
only host 192.168.0.41 failed the task, hosts .42 and .43 continue the
play, the play would abort if all hosts failed.

--
Brian Coca

Brian Coca

unread,
Nov 30, 2015, 9:22:42 PM11/30/15
to Ansible Project

I don't know, those options work for me.

Leon Xie

unread,
Dec 3, 2015, 3:04:42 AM12/3/15
to Ansible Project
thanks a lot for your reply.
Reply all
Reply to author
Forward
0 new messages