david_igou.routeros_configuration.to_indented_yaml filter – Serialize data to YAML with indented block sequences.

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_indented_yaml.

New in david_igou.routeros_configuration 0.0.8-alpha

Synopsis

  • Like to_nice_yaml, but block sequences are indented beneath their parent key instead of PyYAML’s default flush (indentless) style.

  • The flush style trips ansible-lint’s yaml[indentation] rule on every list-bearing key, so files written with to_nice_yaml fail lint above the min profile. Output from this filter passes the default profile, making it suitable for vars files committed to a linted inventory repository (the export_vars role uses it for its captures).

  • Keys are emitted sorted and unicode is preserved, matching to_nice_yaml layout in everything except sequence indentation.

Input

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

Parameter

Comments

Input

any / required

The data structure to serialize.

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

Parameter

Comments

indent

integer

Number of spaces per indentation level.

Default: 2

Examples

- name: Write a captured routeros_config as lint-clean YAML
  ansible.builtin.copy:
    content: "{{ {'routeros_config': routeros_config} | david_igou.routeros_configuration.to_indented_yaml }}"
    dest: "{{ inventory_dir }}/host_vars/{{ inventory_hostname }}.yml"
    mode: "0600"

Return Value

Key

Description

Return value

string

The YAML document as a string, ending in a single newline.

Returned: success

Authors

  • David Igou (@david-igou)