david_igou.routeros_configuration.fetch role – Transfer files to/from RouterOS via /tool fetch.

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

Entry point main – Transfer files to/from RouterOS via /tool fetch.

Synopsis

  • Downloads/uploads files with /tool fetch and removes files with /file remove.

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_fetch

list / elements=dictionary

Files to fetch.

Default: []

dst_path

string / required

Destination file name on the device.

extra

string

Extra fetch arguments appended verbatim.

mode

string

Transfer mode (http/https/ftp/tftp/sftp).

Choices:

  • "http" ← (default)

  • "https"

  • "ftp"

  • "tftp"

  • "sftp"

no_log

boolean

Hide this fetch from logs (set when the URL/extra carries a secret).

Choices:

  • false ← (default)

  • true

url

string / required

Source URL.

routeros_fetch_remove

list / elements=string

File names to delete from the device.

Default: []

Examples

# Download a file onto the device over HTTPS.
- hosts: routers
  gather_facts: false
  roles:
    - role: david_igou.routeros_configuration.fetch
      vars:
        routeros_fetch:
          - url: https://example.com/firmware.npk
            dst_path: firmware.npk
            mode: https

# Download a file, and clean up a stale one with routeros_fetch_remove.
- hosts: routers
  gather_facts: false
  roles:
    - role: david_igou.routeros_configuration.fetch
      vars:
        routeros_fetch:
          - url: https://config.example.com/edge.rsc
            dst_path: edge.rsc
            mode: https
        routeros_fetch_remove:
          - old-edge.rsc

# Fetch over SFTP with extra arguments (appended verbatim); set no_log when
# the URL or arguments carry a credential.
- hosts: routers
  gather_facts: false
  roles:
    - role: david_igou.routeros_configuration.fetch
      vars:
        routeros_fetch:
          - url: sftp://files.example.com/backup.rsc
            dst_path: backup.rsc
            mode: sftp
            extra: "user=svc password={{ vault_sftp_password }}"
            no_log: true