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 |
|---|---|
API hostname/IP of the device. Default: |
|
API password. Secret — supply via vault. |
|
TCP port; empty lets the module choose from tls. Default: |
|
Use TLS (api-ssl). Choices:
|
|
API username. Default: |
|
Validate the device TLS certificate. Choices:
|
|
Targets to ping. Default: |
|
Address to ping. |
|
Number of pings. Default: |
|
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 }}"