I need the exit codes for Ansible for reporting purposes.
The exit status or return code of a process in computer programming is a small number passed from a child process (or callee) to a parent process (or caller) when it has finished executing a specific procedure or delegated task.
Google can’t seem to show me information about the Ansible commandline exit statuses though. So I looked them up & here they are. The exit states were different in older versions, only the more recent versions are compliant with standard Linux exit behaviour.
Ansible exit 0
This includes “no hosts matched”.
Ansible exit 1
Includes wrong options, missing arguments, errors in the playbook, ansible specific errors.
Ansible exit 2
Ansible exit 3
source: source code VERSION 1.7, bin/ansible file.
This should be in the Docs & if I ever figure out where to submit this & what hoops to jump through to get this in there, I will. But first some more work! And in the mean time, at least it’ll be on here..
One thought on “Ansible exit statuses”
Fatal error on fact’s not found produces exit state 3:
(fatal: [localhost] => One or more undefined variables: ‘dict object’ has no attribute ‘ansible_facts’)