david_igou.routeros_configuration.command role – Run arbitrary RouterOS API commands (escape hatch).

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

Entry point main – Run arbitrary RouterOS API commands (escape hatch).

Synopsis

  • Each entry is passed to community.routeros.api. Not idempotent.

Parameters

Parameter

Comments

routeros_api_hostname

string

API hostname/IP of the device.

Default: "{{ inventory_hostname }}"

routeros_api_password

string

API password. Secret — supply via vault.

routeros_api_port

any

TCP port; empty lets the module choose from tls.

Default: ""

routeros_api_tls

boolean

Use TLS (api-ssl).

Choices:

  • false

  • true ← (default)

routeros_api_username

string

API username.

Default: "admin"

routeros_api_validate_certs

boolean

Validate the device TLS certificate.

Choices:

  • false

  • true ← (default)

routeros_command

list / elements=dictionary

Commands to run.

Default: []

add

string

Add arguments (key=value …).

cmd

string

Arbitrary command in the path (e.g. “run .id=*1”).

no_log

boolean

Hide this command from logs (set when it carries a secret).

Choices:

  • false ← (default)

  • true

path

string / required

API path (e.g. “system script”).

remove

string

.id to remove.

update

string

Update arguments (.id=… key=value …).

Examples

# Escape hatch for operations the declarative configure role does not cover.
# NOT idempotent — prefer configure where possible.
#
# cmd op — set the system note.
- hosts: routers
  gather_facts: false
  roles:
    - role: david_igou.routeros_configuration.command
      vars:
        routeros_command:
          - path: system note
            cmd: set note=managed-by-ansible

# add op — create an entry with key=value arguments.
- hosts: routers
  gather_facts: false
  roles:
    - role: david_igou.routeros_configuration.command
      vars:
        routeros_command:
          - path: ip firewall address-list
            add: list=blocklist address=198.51.100.7

# remove op — delete an entry by its .id. Set no_log: true on any command
# whose arguments carry a secret.
- hosts: routers
  gather_facts: false
  roles:
    - role: david_igou.routeros_configuration.command
      vars:
        routeros_command:
          - path: ip firewall address-list
            remove: "*1"