Krikri::ResultDisplay
ResultDisplay - Handles displaying task results and diffs
Class methods
Display an ad-hoc ansible command's result, matching real
ansible's own default ("minimal") callback: host | STATUS | rc=N >>
followed by raw stdout for command-shaped modules (rc + stdout
present - command/shell/script/raw), or host | STATUS => {...}
pretty-printed JSON for every other module. Deliberately NOT
ResultDisplay.display_result - that one renders ansible-playbook's
own "ok: [host]" TASK-recap style, a different output convention
ansible's ad-hoc CLI has never used.
Ad-hoc-only output modifiers, set by krikri.cr (the ansible
counterpart binary) from its own CLI flags:
-o/--one-line switches to real Ansible's deprecated oneline
callback shape - everything on ONE line: command-shaped results
render as host | STATUS | rc=N | (stdout) ... with newlines
escaped (verified against ansible-core 2.19.4's
plugins/callback/oneline.py), everything else renders the result
JSON compact (indent=0, newlines stripped) instead of pretty.
There is no krikri-playbook equivalent to mirror - the playbook CLI
has no -o.
Display an ad-hoc ansible command's result, matching real
ansible's own default ("minimal") callback: host | STATUS | rc=N >>
followed by raw stdout for command-shaped modules (rc + stdout
present - command/shell/script/raw), or host | STATUS => {...}
pretty-printed JSON for every other module. Deliberately NOT
ResultDisplay.display_result - that one renders ansible-playbook's
own "ok: [host]" TASK-recap style, a different output convention
ansible's ad-hoc CLI has never used.
Ad-hoc-only output modifiers, set by krikri.cr (the ansible
counterpart binary) from its own CLI flags:
-o/--one-line switches to real Ansible's deprecated oneline
callback shape - everything on ONE line: command-shaped results
render as host | STATUS | rc=N | (stdout) ... with newlines
escaped (verified against ansible-core 2.19.4's
plugins/callback/oneline.py), everything else renders the result
JSON compact (indent=0, newlines stripped) instead of pretty.
There is no krikri-playbook equivalent to mirror - the playbook CLI
has no -o.
The exact JSON string real Ansible's ad-hoc stdout callbacks dump
after the host | STATUS => prefix. The result dict the callbacks
see has already been through real Ansible's cleaning pipeline by
the time it is dumped: executor/task_result.py's
as_callback_task_result strips failed/skipped for EVERY stdout
callback (a real FAILED! => dump does not contain "failed": true -
live-verified against 2.19.4), and _dump_results strips the private
_ansible_* keys and dumps with sort_keys=True. A debug task
additionally goes through _clean_results - but ONLY in the minimal
(pretty) path: oneline.py never calls it, so an -o debug dump
keeps its other keys (verified live). Status derivation stays with
the caller - stripping here is display-only.
Returns {state word, SGR color code} for an ad-hoc result, mirroring real ansible's minimal/oneline callbacks: unreachable wins over failed, failed over changed. Public so the state-to-color mapping (especially unreachable's distinct bright red, not plain red) can be regression-tested without a live host.
-t/--tree DIR: additionally log each result as pretty JSON in DIR/<hostname>, like real Ansible's tree callback plugin.
-t/--tree DIR: additionally log each result as pretty JSON in DIR/<hostname>, like real Ansible's tree callback plugin.
Display attribute diff (for file attributes like mode, owner)
Display task result with appropriate formatting.
item_label is set for looped tasks, rendering ok: [host] => (item=x)
to match how Ansible annotates per-iteration output.
Show recap of all host results
Show unified diff using system diff command
Update stats based on task result. A failure with ignore_errors: yes still displays as failed (see display_result) but doesn't count toward the host's failure tally - matching Ansible, where an ignored failure doesn't fail the play or the process exit code.