On 25.10.2018 23:28, [email protected] wrote:
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.

--
Kai Stian Olstad

--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3258f4e66678b07a5fcfa8fadb61b7ec%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to