Ansible exit statuses

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.
wikipedia.org/wiki/Exit_status

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
OK
This includes “no hosts matched”.

Ansible exit 1
Something’s wrong.
Includes wrong options, missing arguments, errors in the playbook, ansible specific errors.

Ansible exit 2
Failed hosts

Ansible exit 3
Dark hosts

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..

Published by Gert

Person-at-large.

One thought on “Ansible exit statuses

  1. 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’)

    Like

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: