Hi,
I’m working on an Ansible (2.7.9) playbook ( https://gist.github.com/AllenJB/09f54224a8731467548391e0f093ad33 ) to deploy our project via AWX (4.0.0 via docker) and I’m currently trying to achieve the following:
- The playbook should fail completely (and as soon as possible) if there’s any error, including any unreachable hosts
- AND the playbook should always notify Slack of a failure
So far it seems I’ve only been able to achieve one or the other (my obvious attempts to fail all hosts in notify_failures are not working). The playbook as it stands notifies Slack but then continues on to the lock / build release steps when I purposefully make an inventory item unreachable (change the ssh port to something nothing is running on)
Is there a way I can wrap the entire playbook in a block / rescue while running the items on different host groups? (Where can you use “hosts:” to restrict tasks? Am I right in thinking you can only use hosts: at the top level and not anywhere inside block:? I couldn’t find any examples and the guessed variations I tried didn’t work)
Or is there some other way I can achieve this?
(I’m aware AWX has Slack notifications but they’re not as customizable as I’d like - I’d like to include extra information such as the commit hash)
Thanks in advance
AllenJB