hello,
I have playbook that imports multiple sub play books. Basically, i want the main playbook to shut down the servers sequentially…
main play book:
hello,
I have playbook that imports multiple sub play books. Basically, i want the main playbook to shut down the servers sequentially…
main play book:
main play book:
---
- hosts: all
remote_user: test
become: yes
connection: ssh
gather_facts: false
#ignore_errors: no
#any_errors_fatal: true
You need to enable any_errors_fatal.
===============================================================================
second.yml- name: execute stopEG.sh and shutdown
shell: /home/test/stopEG.sh
register: script_output- debug:
var: script_output
You can use the fail module to stop.
- fail:
msg: "Stopping because of a failure"
when: script_output.failed
- name: shutdown the server now
command: shutdown -h now
when: not script_output.failed(logins to the second server if the script has a execute code of 1, it will
not shutdown the server.)
<snip />
My issue is with the second.yml file i have an exit code of 1, i want the
main playbook to be stopped at the end of second.yml but instead it is just
skipping the shutdown in second.yml and shutting down the servers in third
and fourth playbooks.All i want is playbook to be stopped if there is an error and not shut the
other servers down!
With the proposed changes above this should be the desire effect.
if i enable the any_errors_fatal, if there is no error in the script and if it executes second.yml, it shut downs the server.
when the server is unreachable. because of the any_errors_fatal the script stops at second.yml.
i want the script to run third.yml and fouth.yml if there is no error in the second.yml.