class

Krikri::ActionResult

Inherits Reference < Object

Result from action plugin execution

Constructors

action_failure(error_message : String) : ActionResult

Create a failure result raised by the ACTION plugin itself (a bare AnsibleActionFail - add_host's "name, host or hostname needs to be provided"): rendered action-level, not module-level (see #action_level).

Source
crash_failure(error_message : String, origin : String | Nil = nil, undef_chain : Bool = false) : ActionResult

Create a failure raised by an UNCAUGHT Python exception inside the action plugin - the codec-stack crash Ansible's template action plugin dies with on a non-string output_encoding ("encode() argument 'encoding' must be str, not _AnsibleTaggedInt"), its unknown-codec LookupError, and the #jinja2: directive TypeError (whose crash origin is the template file - see #error_origin). Ansible's task executor wraps such an exception itself, so the fatal dump's msg keeps the "Task failed: " prefix while the [ERROR] block shows the bare message (see #error_detail). undef_chain (see #undef_chain) additionally asks the executor for the failing VALUE's own chained Origin - its var-definition layers.

Source
failure(error_message : String) : ActionResult

Create failure result

Source
final(result : JSON::Any) : ActionResult

Create a final, controller-computed result - no module ever runs.

Source
new(success : Bool, modified_params : Hash(String, String) | Nil = nil, error_message : String | Nil = nil, changed : Bool = false, final_result : JSON::Any | Nil = nil, action_level : Bool = false, error_detail : String | Nil = nil, error_origin : String | Nil = nil, undef_chain : Bool = false)
Source
pass_through

Create pass-through result (no modifications)

Source
success?(modified_params : Hash(String, String), changed : Bool = false) : ActionResult

Create success result

Source

Class methods

conditional_error_result_json(msg : String) : JSON::Any

The result shape for a CONDITIONAL-EVALUATION failure (assert:'s that: hitting an undefined reference or a non-bool result). ansible-core 2.19.11 (live-verified: assert: that: undef_var == 1 with register:) registers changed=false+failed=true+msg and dumps the fatal line as {"changed": false, "msg": "Task failed: ..."} - the same shape as the when:/ path's when_error_result; an older 2.19 build showed a changed-less registered var, but 2.19.11 is the parity target. An ordinary failing assertion still registers changed: false alongside via plugin_result_json.

Source
plugin_result_json(changed : Bool, failed : Bool, msg : String, extra : Hash(String, JSON::Any) = Hash(String, JSON::Any).new, key_order : Array(String) | Nil = nil, include_empty_msg : Bool = false) : JSON::Any

Shared builder for the flat result hash PluginResult#to_json produces (changed/failed/msg + extra fields at the top level, no nesting) - used by every final-result action plugin (action_plugins/*.cr) so each one only needs to name its own extra fields, not re-derive this shape.

Source

Instance methods

action_level=(action_level : Bool)

Set when the failure was raised by the controller-side ACTION plugin itself (a bare AnsibleActionFail): the [ERROR] block is the plain "Task failed: <msg>" chain with no "Module failed." middle segment and the fatal dump's msg stays un-prefixed, unlike a module-side failure. The executor's action-failure result builders turn this into the result's _ansible_action_level key (see ResultDisplay's own branch).

Source
action_level?

Set when the failure was raised by the controller-side ACTION plugin itself (a bare AnsibleActionFail): the [ERROR] block is the plain "Task failed: <msg>" chain with no "Module failed." middle segment and the fatal dump's msg stays un-prefixed, unlike a module-side failure. The executor's action-failure result builders turn this into the result's _ansible_action_level key (see ResultDisplay's own branch).

Source
changed=(changed : Bool)
Source
changed?
Source
error_detail=(error_detail : String | Nil)

The [ERROR] block's own text when it differs from the result's msg. Ansible's task executor wraps an UNCAUGHT Python exception raised inside an action plugin itself ("Task failed: %s" % to_native(e)), so such a failure's fatal msg carries that prefix while the block still shows the bare message - which is what this carries. A deliberate AnsibleActionFail has no prefix in either place, so it stays nil.

Source
error_detail?

The [ERROR] block's own text when it differs from the result's msg. Ansible's task executor wraps an UNCAUGHT Python exception raised inside an action plugin itself ("Task failed: %s" % to_native(e)), so such a failure's fatal msg carries that prefix while the block still shows the bare message - which is what this carries. A deliberate AnsibleActionFail has no prefix in either place, so it stays nil.

Source
error_message
Source
error_message=(error_message : String | Nil)
Source
error_origin=(error_origin : String | Nil)

The file whose Origin the [ERROR] block's CAUSE segment carries when the crash happened while parsing/rendering THAT file rather than in the task's own YAML - ansible's event source context comes from the offending value's own origin tag, so template:'s #jinja2: directive TypeError is reported against the TEMPLATE file (round 1500121, apolloclark.packetbeat). nil = the cause carries no Origin, the shape every other crash_failure has today.

Source
error_origin?

The file whose Origin the [ERROR] block's CAUSE segment carries when the crash happened while parsing/rendering THAT file rather than in the task's own YAML - ansible's event source context comes from the offending value's own origin tag, so template:'s #jinja2: directive TypeError is reported against the TEMPLATE file (round 1500121, apolloclark.packetbeat). nil = the cause carries no Origin, the shape every other crash_failure has today.

Source
final_result

Set only by an action plugin that computes the task's ENTIRE result on the controller and needs no module invocation at all (debug:/ assert:/fail:/set_fact:/pause: - see their own action-plugin files under action_plugins/). When present, the caller (prepare_batch_step / execute_task_once / the handler path) skips plugin upload/dispatch entirely and uses this JSON as the task's result verbatim (still passed through apply_changed_failed_when, same as any other result) - distinct from modified_params, which still expects a real module (local or remote) to run afterward with the substituted params (template:'s own use).

Source
final_result=(final_result : JSON::Any | Nil)

Set only by an action plugin that computes the task's ENTIRE result on the controller and needs no module invocation at all (debug:/ assert:/fail:/set_fact:/pause: - see their own action-plugin files under action_plugins/). When present, the caller (prepare_batch_step / execute_task_once / the handler path) skips plugin upload/dispatch entirely and uses this JSON as the task's result verbatim (still passed through apply_changed_failed_when, same as any other result) - distinct from modified_params, which still expects a real module (local or remote) to run afterward with the substituted params (template:'s own use).

Source
modified_params
Source
modified_params=(modified_params : Hash(String, String) | Nil)
Source
success=(success : Bool)
Source
success?
Source
undef_chain=(undef_chain : Bool)

template:'s undefined-variable render failure (see TemplateAction Plugin): the crash shape PLUS a request for the executor's chained var-origin lookup. When the missing name is reached through a VARIABLE whose stored value is itself an unrendered {{ }} (server_ip: "{{ bind_addr }}"), real 2.19.11 points the [ERROR] chain's variable-templating link at that DEFINITION's file:line:col with a code frame (live-captured) - the executor owns the layers that carry those origins, so the plugin only asks for the scan (it falls back to the crash-shape default, the template file, when the scan finds no unique answer).

Source
undef_chain?

template:'s undefined-variable render failure (see TemplateAction Plugin): the crash shape PLUS a request for the executor's chained var-origin lookup. When the missing name is reached through a VARIABLE whose stored value is itself an unrendered {{ }} (server_ip: "{{ bind_addr }}"), real 2.19.11 points the [ERROR] chain's variable-templating link at that DEFINITION's file:line:col with a code frame (live-captured) - the executor owns the layers that carry those origins, so the plugin only asks for the scan (it falls back to the crash-shape default, the template file, when the scan finds no unique answer).

Source