module

Krikri::PluginHelpers::RunCommandFailure

AnsibleModule.run_command's two failure shapes, for plugins that shell out the way Ansible modules do (module.run_command with check_rc):

  1. An exec that never started (missing or unexecutable binary) surfaces the caught OSError: rc=errno, empty stdout/stderr, msg "Error executing command.", the cleaned (space-joined) command string, and the exception text "[Errno N] <reason>: b'<exe>'". Ansible 2.19 composes the display header as "<msg>: <exception str>" from that exception field while the dumped result keeps the bare msg - krikri's result display mirrors that whenever a failed result carries a real exception value (anything but the "(traceback unavailable)" placeholder).
  2. A started exec that exited non-zero under check_rc=True fails with msg=stderr.rstrip() plus cmd/rc/stdout/stderr (and the _lines splits the display adds).

The errno/reason pairs come from the execve failure the module's subprocess.Popen would see: ENOENT (2, "No such file or directory") for a missing file, EACCES (13, "Permission denied") for an existing non-executable one.

Instance methods

bin_path_missing(name : String, searched_paths : String) : String

Real the Ansible module get_bin_path's ValueError when the binary is nowhere to be found. Real surfaces it as a bare fail_json-style msg (live-verified vs 2.19.11: the fatal msg carries no "Task failed:" chain prefix).

Source
exec_check(exe : String) : Tuple(Int32, String) | Nil

True when exe (an executable override param, used VERBATIM like Ansible's executable.split(" ") - never a PATH search) would fail execve. Returns the errno/reason pair it fails with, or nil when a real subprocess would find and exec it.

Source
exec_failure(exe : String, errno : Int32, reason : String, cmd : String) : Krikri::PluginResult

exec never started (OSError shape). errno/reason describe the execve failure; exe is the binary path exactly as the module passed it (the b'...' quoting is Python's own errno repr).

Source
nonzero_exit(cmd : String, rc : Int32, stdout : String, stderr : String) : Krikri::PluginResult

Non-zero exit under check_rc=True (the sanitized stderr becomes the msg). basic.py's _return_formatted derives stdout_lines/ stderr_lines from the raw output for every fail_json that carries stdout/stderr - and krikri's fatal dump shows the plugin's raw result, so the helper derives them here (Python str.splitlines semantics, empty output -> []).

Source
not_found(exe : String, cmd : String) : Krikri::PluginResult

ENOENT convenience of #exec_failure.

Source
permission_denied(exe : String, cmd : String) : Krikri::PluginResult

EACCES convenience of #exec_failure.

Source