ansible.netcommon.net_ping (6.1.0) — module

Tests reachability using ping from a network device

| "added in version" 1.0.0 of ansible.netcommon"

Authors: Jacob McGill (@jmcgill298)

This plugin has a corresponding action plugin.

Install collection

Install with ansible-galaxy collection install ansible.netcommon:==6.1.0


Add to requirements.yml

  collections:
    - name: ansible.netcommon
      version: 6.1.0

Description

Tests reachability using ping from network device to a remote destination.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Test reachability to 10.10.10.10 using default vrf
  ansible.netcommon.net_ping:
    dest: 10.10.10.10
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Test reachability to 10.20.20.20 using prod vrf
  ansible.netcommon.net_ping:
    dest: 10.20.20.20
    vrf: prod
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Test unreachability to 10.30.30.30 using default vrf
  ansible.netcommon.net_ping:
    dest: 10.30.30.30
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Test reachability to 10.40.40.40 using prod vrf and setting count and source
  ansible.netcommon.net_ping:
    dest: 10.40.40.40
    source: loopback0
    vrf: prod
    count: 20
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- Note:
    - For targets running Python, use the M(ansible.builtin.shell) module along with ping command instead.
    - Example:
        name: ping
        shell: ping -c 1 <remote-ip>

Inputs

    
vrf:
    default: default
    description:
    - The VRF to use for forwarding.

dest:
    description:
    - The IP Address or hostname (resolvable by switch) of the remote node.
    required: true

count:
    default: 5
    description:
    - Number of packets to send.

state:
    choices:
    - absent
    - present
    default: present
    description:
    - Determines if the expected result is success or fail.

source:
    description:
    - The source IP Address.

Outputs

commands:
  description: Show the command sent.
  returned: always
  sample:
  - ping vrf prod 10.40.40.40 count 20 source loopback0
  type: list
packet_loss:
  description: Percentage of packets lost.
  returned: always
  sample: 0%
  type: str
packets_rx:
  description: Packets successfully received.
  returned: always
  sample: 20
  type: int
packets_tx:
  description: Packets successfully transmitted.
  returned: always
  sample: 20
  type: int
rtt:
  description: Show RTT stats.
  returned: always
  sample:
    avg: 2
    max: 8
    min: 1
  type: dict