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 withto_nice_yamlfail lint above theminprofile. Output from this filter passes the default profile, making it suitable for vars files committed to a linted inventory repository (theexport_varsrole uses it for its captures).Keys are emitted sorted and unicode is preserved, matching
to_nice_yamllayout 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 |
|---|---|
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 |
|---|---|
Number of spaces per indentation level. Default: |
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 |
|---|---|
The YAML document as a string, ending in a single newline. Returned: success |