david_igou.routeros_configuration.ping role – Connectivity checks via /tool ping over the API.

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

Entry point main – Connectivity checks via /tool ping over the API.

Synopsis

  • Pings each target; results are registered in _routeros_ping.

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_ping

list / elements=dictionary

Targets to ping.

Default: []

address

string / required

Address to ping.

count

integer

Number of pings.

Default: 4

interface

string

Source interface.

Examples

# Ping a single target.
- hosts: routers
  gather_facts: false
  roles:
    - role: david_igou.routeros_configuration.ping
      vars:
        routeros_ping:
          - address: 1.1.1.1
            count: 3

# Ping several targets.
- hosts: routers
  gather_facts: false
  roles:
    - role: david_igou.routeros_configuration.ping
      vars:
        routeros_ping:
          - address: 1.1.1.1
            count: 4
          - address: 9.9.9.9
            count: 4

# Ping from a source interface and use the registered result. Results are
# in _routeros_ping; .results aligns with routeros_ping and each entry's
# final row carries the running totals.
- hosts: routers
  gather_facts: false
  tasks:
    - name: Ping the gateway from the WAN interface
      ansible.builtin.include_role:
        name: david_igou.routeros_configuration.ping
      vars:
        routeros_ping:
          - address: 192.0.2.1
            interface: ether1
            count: 5
    - name: Show how many replies came back
      ansible.builtin.debug:
        msg: "received {{ (_routeros_ping.results[0].msg | last).received }}"