module

Krikri::ResultDisplay

ResultDisplay - Handles displaying task results and diffs

Class methods

adhoc_oneline=(adhoc_oneline : Bool)

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.

Source
adhoc_oneline?

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.

Source
adhoc_result_json(result : JSON::Any, module_name : String | Nil = nil, oneline : Bool = false) : String

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.

Source
adhoc_state_and_color(changed : Bool, failed : Bool, unreachable : Bool) : Tuple(String, String)

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.

Source
adhoc_tree_dir

-t/--tree DIR: additionally log each result as pretty JSON in DIR/<hostname>, like real Ansible's tree callback plugin.

Source
adhoc_tree_dir=(adhoc_tree_dir : String | Nil)

-t/--tree DIR: additionally log each result as pretty JSON in DIR/<hostname>, like real Ansible's tree callback plugin.

Source
display_adhoc_result(host : Host, result : JSON::Any, diff_mode : Bool = false, module_name : String | Nil = nil) : Nil
Source
display_attribute_diff(diff : JSON::Any) : Nil

Display attribute diff (for file attributes like mode, owner)

Source
display_content_diff(diff : JSON::Any) : Nil

Display content diff (for file content changes)

Source
display_diff(diff : JSON::Any) : Nil

Display diff (delegates to specific diff types)

Source
display_result(host : Host, result : JSON::Any, diff_mode : Bool, item_label : String | Nil = nil, ignore_errors : Bool = false, no_log : Bool = false, module_name : String | Nil = nil) : Nil

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.

Source
show_recap(hosts : Array(Host), results : Hash(String, Hash(String, Int32))) : Nil

Show recap of all host results

Source
show_unified_diff(before : String, after : String) : Nil

Show unified diff using system diff command

Source
update_stats(stats : Hash(String, Int32), result : JSON::Any, ignore_errors : Bool = false) : Nil

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.

Source