StackStorm-Exchange / stackstorm-ansible

st2 content pack containing ansible integrations
https://exchange.stackstorm.org/
Apache License 2.0
36 stars 28 forks source link

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

Closed danleonard80 closed 6 years ago

danleonard80 commented 7 years ago

Hi guys,

I am encountering behavior when executing playbook via StackStorm or using virtualenv ansible that I don't see using plain ansible.

Ran a playbook against 2 hosts: host1 and host2 using StackStorm ansible.playbook action

e.g. Executed command "/opt/stackstorm/virtualenvs/ansible/bin/ansible-playbook --limit=test_hosts test.yml"

Extract of playbook:

roles:

In role c the main task is like:


y.yml is like:


host2 failed a task in y.yml. Task was a command and it actually failed. It was not a connection / ansible error.

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.

This does not happen if I run the same playbook on a plain ansible installation i.e. not using the virtual env ansible

Could anybody please help me to understand why this happens?

Thanks a lot, Daniel

LindsayHill commented 7 years ago

You've gone in the right direction by testing out the playbook using the virtualenv vs default install. That has at least helped isolate it to something in the Ansible setup, rather than ST2.

The first thing I would check is the Ansible versions - do you have the same version in your virtualenv as in your default install?

danleonard80 commented 7 years ago

I have reproduced the issue on virtualenv ansible versions 2.3.2.0 & 2.4.1.0 Non StackStorm Ansible versions 2.3.2.0 and 2.4.0.0 don't behave this way for the same playbook

LindsayHill commented 7 years ago

Something in your ansible configuration then?

I'm not an Ansible expert, I don't understand what controls it has around handling failures. But if it's happening in the virtualenv, it's something specific to Ansible.

Maybe run it with --debug, to get a better understanding of what it's thinking when it ends the play after that failure?

danleonard80 commented 6 years ago

Hi there,

I apologize for the delayed response. You were correct, it was an ansible configuration issue. The virtualenv ansible provided seems to have different default for "any_errors_fatal" than the default install version. Setting "any_errors_fatal: false" explicitly in the playbook gives me the behaviour I wanted i.e. in the example described above host1 would execute the post_tasks.

Thanks again, Daniel