david_igou.routeros_configuration.to_routeros_config filter – Build a routeros_config dict from api_info results.

Note

This filter plugin is part of the david_igou.routeros_configuration collection (version 0.0.8-alpha).

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 david_igou.routeros_configuration.

To use it in a playbook, specify: david_igou.routeros_configuration.to_routeros_config.

New in david_igou.routeros_configuration 0.0.1-alpha

Synopsis

  • Turns the registered results of a looped community.routeros.api_info into the routeros_config structure the configure role consumes.

  • Each entry has its .id removed. Entries left with no settable fields (and paths left with no entries) are omitted, so all-default singletons and empty paths do not clutter the capture. Optionally redacts sensitive field values.

Input

This describes the input of the filter, the value before | david_igou.routeros_configuration.to_routeros_config.

Parameter

Comments

Input

list / elements=dictionary / required

The results list registered from a looped api_info task. Each element exposes item (the slash path) and result (the entries).

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 | david_igou.routeros_configuration.to_routeros_config(key1=value1, key2=value2, ...)

Parameter

Comments

ordered_content

string

The content value (handle_entries_content) emitted for ordered paths. Defaults to remove_as_much_as_possible.

Default: "remove_as_much_as_possible"

ordered_paths

list / elements=string

Slash paths whose entry order is significant. These are emitted with order=true, purge=true and content so the configure role enforces order (api_modify rejects purge with the default content=ignore on these paths).

redact

boolean

Replace the value of any sensitive field with REDACTED.

By default a field is sensitive when its name ends in key, secret, password or passphrase, or is a known secret the suffixes miss (e.g. the WEP static-key-0..3). Known public fields such as a WireGuard peer’s public-key are exempted.

Choices:

  • false ← (default)

  • true

sensitive_fields

list / elements=string

Field names treated as sensitive when redact=true. When set, ONLY these exact names are redacted — the default suffix matching is replaced, not extended.

volatile_fields

dictionary

Mapping of slash path to a list of field names to strip from that path’s entries — either volatile runtime values (e.g. /system/clock date/time) or values that break api_modify’s round-trip matching (e.g. /ip/ipsec/policy group).

Notes

Note

  • Redaction is opt-in. A redacted capture is for review only — the literal REDACTED values do not round-trip; prefer encrypting an unredacted capture with Ansible Vault.

See Also

See also

community.routeros.api_info

The official documentation on the community.routeros.api_info module.

community.routeros.api_modify

The official documentation on the community.routeros.api_modify module.

Examples

- name: Capture paths
  community.routeros.api_info:
    path: "{{ item | replace('/', ' ') | trim }}"
    hide_defaults: true
    include_dynamic: false
    include_read_only: false
  loop: "{{ routeros_export_vars_paths }}"
  register: captured

- name: Assemble routeros_config
  ansible.builtin.set_fact:
    routeros_config: "{{ captured.results | david_igou.routeros_configuration.to_routeros_config }}"

Return Value

Key

Description

Return value

dictionary

A routeros_config dict, keyed by slash path, each with a data list.

Returned: success

Authors

  • David Igou (@david-igou)