stephrobert.scaleway.operation_result filter – Build the machine-readable result of an operation

Note

This filter plugin is part of the stephrobert.scaleway collection (version 0.7.0).

It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install stephrobert.scaleway.

To use it in a playbook, specify: stephrobert.scaleway.operation_result.

Synopsis

  • Returns the common structure every shipped operation emits, so a pipeline, a ticket or a monitoring system can read what happened without parsing standard output.

  • Counts are derived from the names rather than passed alongside them, so a count can never contradict its own list.

Input

This describes the input of the filter, the value before | stephrobert.scaleway.operation_result.

Parameter

Comments

Input

string / required

The operation name, as the collection publishes it.

Keyword parameters

This describes keyword parameters of the filter. These are the values key1=value1, key2=value2 and so on in the following example: input | stephrobert.scaleway.operation_result(key1=value1, key2=value2, ...)

Parameter

Comments

already_compliant

list / elements=string

Names that were already where they should be.

Default: []

changed

list / elements=string

Names the operation changed, or would change in check mode.

Default: []

completed_at

string / required

When it finished, ISO 8601.

mode

string / required

apply when the operation sent what it decided, check when it only said what it would send. In check mode the changed names are the ones that would change.

refused

list / elements=string

Objects the operation saw and set aside, each carrying a name and a reason. A refusal without a reason is an assertion nothing verifies.

Default: []

refused_reason

string

Which field of those objects carries the reason. Defaults to reason; a role setting aside a machine because of its state passes state, so the list never has to be recomposed inside a template.

Default: "reason"

started_at

string / required

When the operation started, ISO 8601.

target

string / required

What the operation acted on, as the caller designated it.

unmeasured

list / elements=string

Names, zones or products the operation could not read. Nothing measured is not nothing found, so these are named rather than counted as zero.

Default: []

Examples

- name: Publish what the operation did
  ansible.builtin.set_fact:
    scaleway_operation: >-
      {{ 'power_schedule' | stephrobert.scaleway.operation_result(
           target='scw_tag_office_hours',
           mode=('check' if ansible_check_mode else 'apply'),
           changed=['web-01', 'web-03'],
           already_compliant=['web-02'],
           refused=[{'name': 'db-01', 'reason': 'locked'}],
           started_at=debut, completed_at=fin) }}

Return Value

Key

Description

Return value

dictionary

The operation result.

Returned: success