Ansible-Playbook Return/Exit Codes

4,255 views
Skip to first unread message

Ansible Madness

unread,
Aug 19, 2015, 10:02:26 PM8/19/15
to Ansible Project

Could someone direct me to a list of ansible-playbook exit codes? So far I've seen 0 which appears to be all OK with changes, however I've also seen 2 and 3. Something official would be great rather than my assumptions :)

I'm attempting to check the exit code of a playbook run to determine if i should run another playbook or not (sorta if a playbook run #1 had any error then run 'recovery' playbook #2)

Any thoughts welcome of course

Ansible version 1.9.2 (RHEL6)



Brian Coca

unread,
Aug 19, 2015, 10:59:07 PM8/19/15
to Ansible Project
no oficial docs, but this is from the new ansible binary in devel:

except AnsibleOptionsError as e:
cli.parser.print_help()
display.error(str(e), wrap_text=False)
sys.exit(5)
except AnsibleParserError as e:
display.error(str(e), wrap_text=False)
sys.exit(4)
except AnsibleHostUnreachable as e:
display.error(str(e))
sys.exit(3)
except AnsibleHostFailed as e:
display.error(str(e))
sys.exit(2)
except AnsibleError as e:
display.error(str(e), wrap_text=False)
sys.exit(1)
except KeyboardInterrupt:
display.error("User interrupted execution")
sys.exit(99)
except Exception as e:
display.error("Unexpected Exception: %s" % str(e), wrap_text=False)
sys.exit(250)



--
Brian Coca
Reply all
Reply to author
Forward
0 new messages