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.