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

I'm just this guy, you know..

Join the Conversation

1 Comment

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

Leave a comment