Krikri::PluginResult
Plugin result structure with diff support
Constructors
Instance methods
Optional wire-key order for the serialized result. Ansible's
registered result is the module's own dict in ITS insertion order
(exit_json's msg/status_code kwargs first, then the module's result
dict, then add_path_info's stat block) - every module has its own,
while PluginResult's fixed leading keys (changed/exception/failed/
msg/diff) impose one engine-wide shape. When set, #to_json emits the
listed keys first, in the listed order (absent ones skipped), then
every remaining key in its current order; nil keeps the historical
order on SUCCESS results, while a FAILED result without a key_order
takes Ansible's plain fail_json order (failed, msg, then extras, then
changed, then exception - see #to_json). Observed programmatically
(e.g. {{ r | to_json }},
{{ r }} in a debug msg) rather than in the -v dump, which real
sorts alphabetically via _dump_results(sort_keys=True).
Optional wire-key order for the serialized result. Ansible's
registered result is the module's own dict in ITS insertion order
(exit_json's msg/status_code kwargs first, then the module's result
dict, then add_path_info's stat block) - every module has its own,
while PluginResult's fixed leading keys (changed/exception/failed/
msg/diff) impose one engine-wide shape. When set, #to_json emits the
listed keys first, in the listed order (absent ones skipped), then
every remaining key in its current order; nil keeps the historical
order on SUCCESS results, while a FAILED result without a key_order
takes Ansible's plain fail_json order (failed, msg, then extras, then
changed, then exception - see #to_json). Observed programmatically
(e.g. {{ r | to_json }},
{{ r }} in a debug msg) rather than in the -v dump, which real
sorts alphabetically via _dump_results(sort_keys=True).
A NATIVE-typed msg override (JSON::Any): Ansible modules that pass a
non-string value to fail_json/exit_json keep its Python type in the
wire result (fail's action puts the raw task arg in result['msg'],
so fail: {msg: 50} registers and dumps the INT 50, not "50") -
the strings-only @msg cannot carry that. When set it replaces @msg
in the serialized result entirely; @msg stays "" (the display layer
re-renders a non-string msg through Python repr for its error
blocks).
A NATIVE-typed msg override (JSON::Any): Ansible modules that pass a
non-string value to fail_json/exit_json keep its Python type in the
wire result (fail's action puts the raw task arg in result['msg'],
so fail: {msg: 50} registers and dumps the INT 50, not "50") -
the strings-only @msg cannot carry that. When set it replaces @msg
in the serialized result entirely; @msg stays "" (the display layer
re-renders a non-string msg through Python repr for its error
blocks).