.. _juniper_junos_ping: juniper_junos_ping ++++++++++++++++++ Execute ping from a Junos device .. versionadded:: 2.0.0 .. contents:: :local: :depth: 2 Synopsis -------- * Execute the ping command from a Junos device to a specified destination in order to test network reachability from the Junos device . Requirements ------------ The following software packages must be installed on hosts that execute this module: * `junos-eznc `_ >= 2.1.7 * Python >= 2.7 .. _module-specific-options-label: Module-specific Options ----------------------- The following options may be specified for this module: .. raw:: html
parameter type required default choices comments
acceptable_percent_loss
int no 0
Maximum percentage of packets that may be lost and still consider the task not to have failed.

aliases: acceptable_packet_loss
count
int no 5
Number of packets to send.
dest
str yes none
The IP address, or hostname if DNS is configured on the Junos device, used as the destination of the ping.

aliases: dest_ip, dest_host, destination, destination_ip, destination_host
do_not_fragment
bool no False
  • yes
  • no
Set Do Not Fragment bit on ping packets.
interface
str no none
The source interface from which the the ping is sent. If not specified, the default Junos algorithm for determining the source interface is used.
rapid
bool no True
  • yes
  • no
Send ping requests rapidly
routing_instance
str no none
Name of the source routing instance from which the ping is originated. If not specified, the default routing instance is used.
size
int no none (default size for device)
The size of the ICMP payload of the ping.
Total size of the IP packet is size + the 20 byte IP header + the 8 byte ICMP header. Therefore, size of 1472 generates an IP packet of size 1500.
source
str no none
The IP address, or hostname if DNS is configured on the Junos device, used as the source address of the ping. If not specified, the Junos default algorithm for determining the source address is used.

aliases: source_ip, source_host, src, src_ip, src_host
ttl
int no none (default ttl for device)
Maximum number of IP routers (hops) allowed between source and destination.

Common Connection-related Options --------------------------------- In addition to the :ref:`module-specific-options-label`, the following connection-related options are also supported by this module: .. raw:: html
parameter type required default choices comments
attempts
int no 10
The number of times to try connecting and logging in to the Junos device. This option is only applicable when using mode = 'telnet' or mode = 'serial'. Mutually exclusive with the console option.
baud
int no 9600
The serial baud rate, in bits per second, used to connect to the Junos device. This option is only applicable when using mode = 'serial'. Mutually exclusive with the console option.
console
str no none
An alternate method of specifying a NETCONF over serial console connection to the Junos device using Telnet to a console server. The value of this option must be a string in the format --telnet <console_hostname>,<console_port_number>. This option is deprecated. It is present only for backwards compatibility. The string value of this option is exactly equivalent to specifying host with a value of <console_hostname>, mode with a value of telnet, and port with a value of <console_port_number>. Mutually exclusive with the mode, port, baud, and attempts options.
host
str yes {{ inventory_hostname }}
The hostname or IP address of the Junos device to which the connection should be established. This is normally the Junos device itself, but is the hostname or IP address of a console server when connecting to the console of the device by setting the mode option to the value telnet. This option is required, but does not have to be specified explicitly by the user because it defaults to {{ inventory_hostname }}.

aliases: hostname, ip
mode
str no none
  • none
  • telnet
  • serial
The PyEZ mode used to establish a NETCONF connection to the Junos device. A value of none uses the default NETCONF over SSH mode. Depending on the values of the host and port options, a value of telnet results in either a direct NETCONF over Telnet connection to the Junos device, or a NETCONF over serial console connection to the Junos device using Telnet to a console server. A value of serial results in a NETCONF over serial console connection to the Junos device. Mutually exclusive with the console option.
passwd
str no The first defined value from the following list 1) The ANSIBLE_NET_PASSWORD environment variable. (used by Ansible Tower) 2) The value specified using the -k or --ask-pass command line arguments to the ansible or ansible-playbook command. 3) none (An empty password/passphrase)
The password, or ssh key's passphrase, used to authenticate with the Junos device. If this option is not specified, authentication is attempted using an empty password, or ssh key passphrase.

aliases: password
port
int or str no 830 if mode = none, 23 if mode = 'telnet', '/dev/ttyUSB0' if (mode = 'serial')
The TCP port number or serial device port used to establish the connection. Mutually exclusive with the console option.
provider
dict no
An alternative syntax for specifying the connection options. Rather than specifying each connection-related top-level option, the connection-related options may be specified as a dictionary of suboptions to the provider option. All connection-related options must either be specified as top-level options or as suboptions of the provider option. You can not combine the two methods of specifying connection-related options.
Dictionary object provider
parameter type required default choices comments
baud
int no 9600
The serial baud rate, in bits per second, used to connect to the Junos device. This option is only applicable when using mode = 'serial'. Mutually exclusive with the console option.
attempts
int no 10
The number of times to try connecting and logging in to the Junos device. This option is only applicable when using mode = 'telnet' or mode = 'serial'. Mutually exclusive with the console option.
console
str no none
An alternate method of specifying a NETCONF over serial console connection to the Junos device using Telnet to a console server. The value of this option must be a string in the format --telnet <console_hostname>,<console_port_number>. This option is deprecated. It is present only for backwards compatibility. The string value of this option is exactly equivalent to specifying host with a value of <console_hostname>, mode with a value of telnet, and port with a value of <console_port_number>. Mutually exclusive with the mode, port, baud, and attempts options.
passwd
str no The first defined value from the following list 1) The ANSIBLE_NET_PASSWORD environment variable. (used by Ansible Tower) 2) The value specified using the -k or --ask-pass command line arguments to the ansible or ansible-playbook command. 3) none (An empty password/passphrase)
The password, or ssh key's passphrase, used to authenticate with the Junos device. If this option is not specified, authentication is attempted using an empty password, or ssh key passphrase.
ssh_config
path no
The path to the SSH client configuration file. If this option is not specified, then the PyEZ Device instance by default queries file ~/.ssh/config.
host
str yes {{ inventory_hostname }}
The hostname or IP address of the Junos device to which the connection should be established. This is normally the Junos device itself, but is the hostname or IP address of a console server when connecting to the console of the device by setting the mode option to the value telnet. This option is required, but does not have to be specified explicitly by the user because it defaults to {{ inventory_hostname }}.
mode
str no none
  • none
  • telnet
  • serial
The PyEZ mode used to establish a NETCONF connection to the Junos device. A value of none uses the default NETCONF over SSH mode. Depending on the values of the host and port options, a value of telnet results in either a direct NETCONF over Telnet connection to the Junos device, or a NETCONF over serial console connection to the Junos device using Telnet to a console server. A value of serial results in a NETCONF over serial console connection to the Junos device. Mutually exclusive with the console option.
timeout
int no 30
The maximum number of seconds to wait for RPC responses from the Junos device. This option does NOT control the initial connection timeout value.
ssh_private_key_file
path no The first defined value from the following list 1) The ANSIBLE_NET_SSH_KEYFILE environment variable. (used by Ansible Tower) 2) The value specified using the --private-key or --key-file command line arguments to the ansible or ansible-playbook command. 3) none (the file specified in the user's SSH configuration, or the operating-system-specific default)
The path to the SSH private key file used to authenticate with the Junos device. If this option is not specified, and no default value is found using the algorithm below, then the SSH private key file specified in the user's SSH configuration, or the operating-system-specific default is used.
port
int or str no 830 if mode = none, 23 if mode = 'telnet', '/dev/ttyUSB0' if (mode = 'serial')
The TCP port number or serial device port used to establish the connection. Mutually exclusive with the console option.
user
str yes The first defined value from the following list 1) The ANSIBLE_NET_USERNAME environment variable. (used by Ansible Tower) 2) The remote_user as defined by Ansible. Ansible sets this value via several methods including a) -u or --user command line arguments to the ansible or ansible-playbook command. b) ANSIBLE_REMOTE_USER environment variable. c) remote_user configuration setting. See the Ansible documentation for the precedence used to set the remote_user value. 3) The USER environment variable.
The username used to authenticate with the Junos device. This option is required, but does not have to be specified explicitly by the user due to the algorithm for determining the default value.
ssh_config
path no
The path to the SSH client configuration file. If this option is not specified, then the PyEZ Device instance by default queries file ~/.ssh/config.
ssh_private_key_file
path no The first defined value from the following list 1) The ANSIBLE_NET_SSH_KEYFILE environment variable. (used by Ansible Tower) 2) The value specified using the --private-key or --key-file command line arguments to the ansible or ansible-playbook command. 3) none (the file specified in the user's SSH configuration, or the operating-system-specific default)
The path to the SSH private key file used to authenticate with the Junos device. If this option is not specified, and no default value is found using the algorithm below, then the SSH private key file specified in the user's SSH configuration, or the operating-system-specific default is used.

aliases: ssh_keyfile
timeout
int no 30
The maximum number of seconds to wait for RPC responses from the Junos device. This option does NOT control the initial connection timeout value.
user
str yes The first defined value from the following list 1) The ANSIBLE_NET_USERNAME environment variable. (used by Ansible Tower) 2) The remote_user as defined by Ansible. Ansible sets this value via several methods including a) -u or --user command line arguments to the ansible or ansible-playbook command. b) ANSIBLE_REMOTE_USER environment variable. c) remote_user configuration setting. See the Ansible documentation for the precedence used to set the remote_user value. 3) The USER environment variable.
The username used to authenticate with the Junos device. This option is required, but does not have to be specified explicitly by the user due to the algorithm for determining the default value.

aliases: username

Common Logging-related Options ------------------------------ In addition to the :ref:`module-specific-options-label`, the following logging-related options are also supported by this module: .. raw:: html
parameter type required default choices comments
level
str no WARNING
  • INFO
  • DEBUG
The level of information to be logged can be modified using this option
1) By default, messages at level WARNING or higher are logged.
2) If the -v or --verbose command-line options to the ansible-playbook command are specified, messages at level INFO or higher are logged.
3) If the -vv (or more verbose) command-line option to the ansible-playbook command is specified, or the ANSIBLE_DEBUG environment variable is set, then messages at level DEBUG or higher are logged.
4) If level is mentioned then messages at level level or more are logged.
logdir
path no none
The path to a directory, on the Ansible control machine, where debugging information for the particular task is logged.
If this option is specified, debugging information is logged to a file named {{ inventory_hostname }}.log in the directory specified by the logdir option.
The log file must be writeable. If the file already exists, it is appended. It is the users responsibility to delete/rotate log files.
The level of information logged in this file is controlled by Ansible's verbosity, debug options and level option in task
1) By default, messages at level WARNING or higher are logged.
2) If the -v or --verbose command-line options to the ansible-playbook command are specified, messages at level INFO or higher are logged.
3) If the -vv (or more verbose) command-line option to the ansible-playbook command is specified, or the ANSIBLE_DEBUG environment variable is set, then messages at level DEBUG or higher are logged.
4) If level is mentioned then messages at level level or more are logged.
The logfile and logdir options are mutually exclusive. The logdir option is recommended for all new playbooks.

aliases: log_dir
logfile
path no none
The path to a file, on the Ansible control machine, where debugging information for the particular task is logged.
The log file must be writeable. If the file already exists, it is appended. It is the users responsibility to delete/rotate log files.
The level of information logged in this file is controlled by Ansible's verbosity, debug options and level option in task
1) By default, messages at level WARNING or higher are logged.
2) If the -v or --verbose command-line options to the ansible-playbook command are specified, messages at level INFO or higher are logged.
3) If the -vv (or more verbose) command-line option to the ansible-playbook command is specified, or the ANSIBLE_DEBUG environment variable is set, then messages at level DEBUG or higher are logged.
4) If level is mentioned then messages at level level or more are logged.
When tasks are executed against more than one target host, one process is forked for each target host. (Up to the maximum specified by the forks configuration. See forks for details.) This means that the value of this option must be unique per target host. This is usually accomplished by including {{ inventory_hostname }} in the logfile value. It is the user's responsibility to ensure this value is unique per target host.
For this reason, this option is deprecated. It is maintained for backwards compatibility. Use the logdir option in new playbooks. The logfile and logdir options are mutually exclusive.

aliases: log_file

.. _juniper_junos_ping-examples-label: Examples -------- :: --- - name: Examples of juniper_junos_ping hosts: junos-all connection: local gather_facts: no roles: - Juniper.junos tasks: - name: Ping 10.0.0.1 with default parameters. Fails if any packets lost. juniper_junos_ping: dest: "10.0.0.1" - name: Ping 10.0.0.1. Allow 50% packet loss. Register response. juniper_junos_ping: dest: "10.0.0.1" acceptable_percent_loss: 50 register: response - name: Print all keys in the response. debug: var: response - name: Ping 10.0.0.1. Send 20 packets. Register response. juniper_junos_ping: dest: "10.0.0.1" count: 20 register: response - name: Print packet sent from the response. debug: var: response.packets_sent - name: Ping 10.0.0.1. Send 10 packets wihtout rapid. Register response. juniper_junos_ping: dest: "10.0.0.1" count: 10 rapid: false register: response - name: Print the average round-trip-time from the response. debug: var: response.rtt_average - name: Ping www.juniper.net with ttl 15. Register response. juniper_junos_ping: dest: "www.juniper.net" ttl: 15 register: response - name: Print the packet_loss percentage from the response. debug: var: response.packet_loss - name: Ping 10.0.0.1 with IP packet size of 1500. Register response. juniper_junos_ping: dest: "10.0.0.1" size: 1472 register: response - name: Print the packets_received from the response. debug: var: response.packets_received - name: Ping 10.0.0.1 with do-not-fragment bit set. Register response. juniper_junos_ping: dest: "10.0.0.1" do_not_fragment: true register: response - name: Print the maximum round-trip-time from the response. debug: var: response.rtt_maximum - name: Ping 10.0.0.1 with source set to 10.0.0.2. Register response. juniper_junos_ping: dest: "10.0.0.1" source: "10.0.0.2" register: response - name: Print the source from the response. debug: var: response.source - name: Ping 192.168.1.1 from the red routing-instance. juniper_junos_ping: dest: "192.168.1.1" routing_instance: "red" - name: Ping the all-hosts multicast address from the ge-0/0/0.0 interface juniper_junos_ping: dest: "224.0.0.1" interface: "ge-0/0/0.0" Return Values ------------- .. raw:: html
name description returned type sample
acceptable_percent_loss
The acceptable packet loss (as a percentage) for this task as specified by the acceptable_percent_loss option.
when ping successfully executed, even if the acceptable_percent_loss was exceeded. str
changed
Indicates if the device's state has changed. Since this module doesn't change the operational or configuration state of the device, the value is always set to false.
when ping successfully executed, even if the acceptable_percent_loss was exceeded. bool
count
The number of pings sent, as specified by the count option.
when ping successfully executed, even if the acceptable_percent_loss was exceeded. str
do_not_fragment
Whether or not the do not fragment bit was set on the pings sent, as specified by the do_not_fragment option.
when ping successfully executed, even if the acceptable_percent_loss was exceeded. bool
failed
Indicates if the task failed.
always bool
host
The destination IP/host of the pings sent as specified by the dest option.
Keys dest and dest_ip are also returned for backwards compatibility.
when ping successfully executed, even if the acceptable_percent_loss was exceeded. str
interface
The source interface of the pings sent as specified by the interface option.
when ping successfully executed and the interface option was specified, even if the acceptable_percent_loss was exceeded. str
msg
A human-readable message indicating the result.
always str
packet_loss
The percentage of packets lost.
when ping successfully executed, even if the acceptable_percent_loss was exceeded. str
packets_received
The number of packets received.
when ping successfully executed, even if the acceptable_percent_loss was exceeded. str
packets_sent
The number of packets sent.
when ping successfully executed, even if the acceptable_percent_loss was exceeded. str
rapid
Whether or not the pings were sent rapidly, as specified by the rapid option.
when ping successfully executed, even if the acceptable_percent_loss was exceeded. bool
routing_instance
The routing-instance from which the pings were sent as specified by the routing_instance option.
when ping successfully executed and the routing_instance option was specified, even if the acceptable_percent_loss was exceeded. str
rtt_average
The average round-trip-time, in microseconds, of all ping responses received.
when ping successfully executed, and packet_loss < 100%. str
rtt_maximum
The maximum round-trip-time, in microseconds, of all ping responses received.
when ping successfully executed, and packet_loss < 100%. str
rtt_minimum
The minimum round-trip-time, in microseconds, of all ping responses received.
when ping successfully executed, and packet_loss < 100%. str
rtt_stddev
The standard deviation of round-trip-time, in microseconds, of all ping responses received.
when ping successfully executed, and packet_loss < 100%. str
size
The size in bytes of the ICMP payload on the pings sent as specified by the size option.
Total size of the IP packet is size + the 20 byte IP header + the 8 byte ICMP header. Therefore, size of 1472 generates an IP packet of size 1500.
when ping successfully executed and the size option was specified, even if the acceptable_percent_loss was exceeded. str
source
The source IP/host of the pings sent as specified by the source option.
Key source_ip is also returned for backwards compatibility.
when ping successfully executed and the source option was specified, even if the acceptable_percent_loss was exceeded. str
timeout
The number of seconds to wait for a response from the ping RPC.
when ping successfully executed, even if the acceptable_percent_loss was exceeded. str
ttl
The time-to-live set on the pings sent as specified by the ttl option.
when ping successfully executed and the ttl option was specified, even if the acceptable_percent_loss was exceeded. str
warnings
A list of warning strings, if any, produced from the ping.
when warnings are present list


Notes ----- .. note:: - The NETCONF system service must be enabled on the target Junos device. Author ~~~~~~ * Juniper Networks - Stacy Smith (@stacywsmith) Status ~~~~~~ This module is flagged as **stableinterface** which means that the maintainers for this module guarantee that no backward incompatible interface changes will be made.