Skip to content

Exit codes

lemano exits with a code that says what kind of failure happened, so a script can tell an unreachable host from a held lock or a broken history. lemano --help lists the same codes. With -o json, a failure also prints a JSON error object that carries the code and a reason a script can test: see scripting.

CodeMeaning
0Success: the command did what it was asked.
1Any failure without a code of its own; also a revert that was cancelled, or a trial that was not kept.
2Usage: an unknown command or flag, a missing argument, an invalid selector; also a revert or target end-trial refused for a trial (reasons TrialPending, UnfinishedTrial, NoUnfinishedTrial). See lemano ansible for its extra cases.
3Connection: a target could not be reached (network, authentication, credential, connect timeout); also the fresh login after a revert trial’s write.
4Host identity: an unknown, changed or unexpected host key (one the target’s hostKey setting does not name), a fingerprint mismatch, or a changed machine identity.
5Lock held: another command holds a target’s lock.
6Integrity: the recorded history does not verify, or is corrupt; also sealed data in the store (a file’s content, a secret) that does not open whole.
7Partial: a pass completed but could not read everything. On a target declared with privilege: user, what it cannot read for lack of privilege is skipped (needs root) and does not count; neither does a gap the target file accepts with acceptNotRead, a file that vanished between listing and reading, or a kernel parameter of the host (see What a pass does not read). Also revert, when at least one change was not applied (a file changed since the preview, a failed check).
8Changed: only with --detailed-exitcode. discover: at least one generation was written and nothing failed. summary: at least one target needs attention (a condition, not read as expected, or changed; see summary).
9Confirmation required: revert (and lemano ansible revert) would write and there is nobody to approve it (no terminal, or -o json/-o yaml, and no --expect-plan or --auto-approve), or the plan it built is not the one whose digest --expect-plan named. It showed the plan as --dry-run does, wrote nothing on the server and recorded no revert; the error holds the command, with --expect-plan DIGEST, that approves the plan shown.
130Interrupted (Ctrl-C).

lemano ansible

lemano ansible uses the same codes, with the same meaning for the same failure: a failure of an API reason has the code of that reason (a held lock is 5, an unreachable host 3, a host key that is not pinned or has changed 4). It adds these cases:

  • 2: check and codify, when the playbook has tasks that run for real in check mode and --allow-unsafe-tasks was not given; codify, when its --out file exists or the edits are not approved.
  • 7: import, when at least one host could not be imported (a host that is not reached over SSH does not count), after the targets were printed or written; check and codify, when a host could not be read or compared.
  • 8, only with --detailed-exitcode: check, when something is drifted, missing or forgotten (see ansible check).

Several targets

With several targets the highest failure code is returned. A failure (1 to 7, 9, 130) always takes precedence over 8, so a change never hides one. Without --detailed-exitcode, a discover that wrote generations and failed nowhere exits 0.

New codes may be added in later versions: treat any code a script does not know as a failure.