david_igou.routeros_configuration.export_vars role – Capture a running device’s config into a routeros_config vars file.
Note
This role 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.export_vars.
Entry point main – Capture a running device’s config into a routeros_config vars file.
Synopsis
The reverse of the
configurerole. Reads the device over the API (community.routeros.api_info) and writes a per-host vars file containing arouteros_configdict that theconfigurerole can re-apply.Captured fields are a best-effort equivalent; review before re-applying.
Parameters
Parameter |
Comments |
|---|---|
API hostname/IP of the device. Default: |
|
API password. Secret — supply via vault. The module marks it no_log. |
|
TCP port; empty lets the module choose from tls. Default: |
|
Use TLS (api-ssl). Choices:
|
|
API username. Default: |
|
Validate the device TLS certificate. Choices:
|
|
Controller directory for the captured Default: |
|
Slash paths to exclude from the export even when they are configure-modifiable — paths that capture runtime state, hardware enumeration, or auto-generated defaults rather than intent (e.g. |
|
Additional slash paths to exclude, merged onto Default: |
|
How Choices:
|
|
The Choices:
|
|
Slash paths whose entry order is significant (firewall chains, routing filters, simple queues). Captured with |
|
Slash paths to capture. When unset, defaults to the configure role’s full |
|
Replace sensitive field values (keys, PSKs, passwords) with Choices:
|
|
Per-path fields stripped from the capture. Keys are slash paths, values are lists of field names. Drop a field here when it is either volatile device state (not config) or a value that breaks |
Examples
# Capture the full configuration. Writes <inventory_hostname>.yml with a
# routeros_config dict that the configure role can re-apply.
- hosts: routers
gather_facts: false
roles:
- role: david_igou.routeros_configuration.export_vars
vars:
routeros_export_vars_dir: ./routeros-vars
# Capture a focused set of paths for a fast, targeted snapshot. Paths with
# no entries are omitted from the output.
- hosts: routers
gather_facts: false
roles:
- role: david_igou.routeros_configuration.export_vars
vars:
routeros_export_vars_paths:
- /ip/address
- /system/identity
# Redact secrets (keys, PSKs, passwords) as REDACTED. The output no longer
# round-trips; prefer encrypting the unredacted file with Ansible Vault.
- hosts: routers
gather_facts: false
roles:
- role: david_igou.routeros_configuration.export_vars
vars:
routeros_export_vars_redact: true