1.. _junipernetworks.junos.junos_ping_module:
2
3
4********************************
5junipernetworks.junos.junos_ping
6********************************
7
8**Tests reachability using ping from devices running Juniper JUNOS**
9
10
11Version added: 1.0.0
12
13.. contents::
14   :local:
15   :depth: 1
16
17
18Synopsis
19--------
20- Tests reachability using ping from devices running Juniper JUNOS to a remote destination.
21- Tested against Junos (17.3R1.10)
22- For a general purpose network module, see the :ref:`ansible.netcommon.net_ping <ansible.netcommon.net_ping_module>` module.
23- For Windows targets, use the :ref:`ansible.windows.win_ping <ansible.windows.win_ping_module>` module instead.
24- For targets running Python, use the :ref:`ansible.builtin.ping <ansible.builtin.ping_module>` module instead.
25
26
27
28
29Parameters
30----------
31
32.. raw:: html
33
34    <table  border=0 cellpadding=0 class="documentation-table">
35        <tr>
36            <th colspan="2">Parameter</th>
37            <th>Choices/<font color="blue">Defaults</font></th>
38            <th width="100%">Comments</th>
39        </tr>
40            <tr>
41                <td colspan="2">
42                    <div class="ansibleOptionAnchor" id="parameter-"></div>
43                    <b>count</b>
44                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
45                    <div style="font-size: small">
46                        <span style="color: purple">integer</span>
47                    </div>
48                </td>
49                <td>
50                        <b>Default:</b><br/><div style="color: blue">5</div>
51                </td>
52                <td>
53                        <div>Number of packets to send to check reachability.</div>
54                </td>
55            </tr>
56            <tr>
57                <td colspan="2">
58                    <div class="ansibleOptionAnchor" id="parameter-"></div>
59                    <b>dest</b>
60                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
61                    <div style="font-size: small">
62                        <span style="color: purple">string</span>
63                         / <span style="color: red">required</span>
64                    </div>
65                </td>
66                <td>
67                </td>
68                <td>
69                        <div>The IP Address or hostname (resolvable by the device) of the remote node.</div>
70                </td>
71            </tr>
72            <tr>
73                <td colspan="2">
74                    <div class="ansibleOptionAnchor" id="parameter-"></div>
75                    <b>df_bit</b>
76                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
77                    <div style="font-size: small">
78                        <span style="color: purple">boolean</span>
79                    </div>
80                </td>
81                <td>
82                        <ul style="margin: 0; padding: 0"><b>Choices:</b>
83                                    <li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
84                                    <li>yes</li>
85                        </ul>
86                </td>
87                <td>
88                        <div>Determines whether to set the DF bit.</div>
89                </td>
90            </tr>
91            <tr>
92                <td colspan="2">
93                    <div class="ansibleOptionAnchor" id="parameter-"></div>
94                    <b>interface</b>
95                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
96                    <div style="font-size: small">
97                        <span style="color: purple">string</span>
98                    </div>
99                </td>
100                <td>
101                </td>
102                <td>
103                        <div>The source interface to use while sending the ping packet(s).</div>
104                </td>
105            </tr>
106            <tr>
107                <td colspan="2">
108                    <div class="ansibleOptionAnchor" id="parameter-"></div>
109                    <b>interval</b>
110                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
111                    <div style="font-size: small">
112                        <span style="color: purple">integer</span>
113                    </div>
114                </td>
115                <td>
116                </td>
117                <td>
118                        <div>Determines the interval (in seconds) between consecutive pings.</div>
119                </td>
120            </tr>
121            <tr>
122                <td colspan="2">
123                    <div class="ansibleOptionAnchor" id="parameter-"></div>
124                    <b>provider</b>
125                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
126                    <div style="font-size: small">
127                        <span style="color: purple">dictionary</span>
128                    </div>
129                </td>
130                <td>
131                </td>
132                <td>
133                        <div><b>Deprecated</b></div>
134                        <div>Starting with Ansible 2.5 we recommend using <code>connection: network_cli</code> or <code>connection: netconf</code>.</div>
135                        <div>For more information please see the <a href='../network/user_guide/platform_junos.html'>Junos OS Platform Options guide</a>.</div>
136                        <div><hr/></div>
137                        <div>A dict object containing connection details.</div>
138                </td>
139            </tr>
140                                <tr>
141                    <td class="elbow-placeholder"></td>
142                <td colspan="1">
143                    <div class="ansibleOptionAnchor" id="parameter-"></div>
144                    <b>host</b>
145                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
146                    <div style="font-size: small">
147                        <span style="color: purple">string</span>
148                    </div>
149                </td>
150                <td>
151                </td>
152                <td>
153                        <div>Specifies the DNS host name or address for connecting to the remote device over the specified transport.  The value of host is used as the destination address for the transport.</div>
154                </td>
155            </tr>
156            <tr>
157                    <td class="elbow-placeholder"></td>
158                <td colspan="1">
159                    <div class="ansibleOptionAnchor" id="parameter-"></div>
160                    <b>password</b>
161                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
162                    <div style="font-size: small">
163                        <span style="color: purple">string</span>
164                    </div>
165                </td>
166                <td>
167                </td>
168                <td>
169                        <div>Specifies the password to use to authenticate the connection to the remote device.   This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_PASSWORD</code> will be used instead.</div>
170                </td>
171            </tr>
172            <tr>
173                    <td class="elbow-placeholder"></td>
174                <td colspan="1">
175                    <div class="ansibleOptionAnchor" id="parameter-"></div>
176                    <b>port</b>
177                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
178                    <div style="font-size: small">
179                        <span style="color: purple">integer</span>
180                    </div>
181                </td>
182                <td>
183                </td>
184                <td>
185                        <div>Specifies the port to use when building the connection to the remote device.  The port value will default to the well known SSH port of 22 (for <code>transport=cli</code>) or port 830 (for <code>transport=netconf</code>) device.</div>
186                </td>
187            </tr>
188            <tr>
189                    <td class="elbow-placeholder"></td>
190                <td colspan="1">
191                    <div class="ansibleOptionAnchor" id="parameter-"></div>
192                    <b>ssh_keyfile</b>
193                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
194                    <div style="font-size: small">
195                        <span style="color: purple">path</span>
196                    </div>
197                </td>
198                <td>
199                </td>
200                <td>
201                        <div>Specifies the SSH key to use to authenticate the connection to the remote device.   This value is the path to the key used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_SSH_KEYFILE</code> will be used instead.</div>
202                </td>
203            </tr>
204            <tr>
205                    <td class="elbow-placeholder"></td>
206                <td colspan="1">
207                    <div class="ansibleOptionAnchor" id="parameter-"></div>
208                    <b>timeout</b>
209                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
210                    <div style="font-size: small">
211                        <span style="color: purple">integer</span>
212                    </div>
213                </td>
214                <td>
215                </td>
216                <td>
217                        <div>Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands.  If the timeout is exceeded before the operation is completed, the module will error.</div>
218                </td>
219            </tr>
220            <tr>
221                    <td class="elbow-placeholder"></td>
222                <td colspan="1">
223                    <div class="ansibleOptionAnchor" id="parameter-"></div>
224                    <b>transport</b>
225                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
226                    <div style="font-size: small">
227                        <span style="color: purple">string</span>
228                    </div>
229                </td>
230                <td>
231                        <ul style="margin: 0; padding: 0"><b>Choices:</b>
232                                    <li>cli</li>
233                                    <li><div style="color: blue"><b>netconf</b>&nbsp;&larr;</div></li>
234                        </ul>
235                </td>
236                <td>
237                        <div>Configures the transport connection to use when connecting to the remote device.</div>
238                </td>
239            </tr>
240            <tr>
241                    <td class="elbow-placeholder"></td>
242                <td colspan="1">
243                    <div class="ansibleOptionAnchor" id="parameter-"></div>
244                    <b>username</b>
245                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
246                    <div style="font-size: small">
247                        <span style="color: purple">string</span>
248                    </div>
249                </td>
250                <td>
251                </td>
252                <td>
253                        <div>Configures the username to use to authenticate the connection to the remote device.  This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_USERNAME</code> will be used instead.</div>
254                </td>
255            </tr>
256
257            <tr>
258                <td colspan="2">
259                    <div class="ansibleOptionAnchor" id="parameter-"></div>
260                    <b>rapid</b>
261                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
262                    <div style="font-size: small">
263                        <span style="color: purple">boolean</span>
264                    </div>
265                </td>
266                <td>
267                        <ul style="margin: 0; padding: 0"><b>Choices:</b>
268                                    <li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
269                                    <li>yes</li>
270                        </ul>
271                </td>
272                <td>
273                        <div>Determines whether to send the packets rapidly.</div>
274                </td>
275            </tr>
276            <tr>
277                <td colspan="2">
278                    <div class="ansibleOptionAnchor" id="parameter-"></div>
279                    <b>size</b>
280                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
281                    <div style="font-size: small">
282                        <span style="color: purple">integer</span>
283                    </div>
284                </td>
285                <td>
286                </td>
287                <td>
288                        <div>Determines the size (in bytes) of the ping packet(s).</div>
289                </td>
290            </tr>
291            <tr>
292                <td colspan="2">
293                    <div class="ansibleOptionAnchor" id="parameter-"></div>
294                    <b>source</b>
295                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
296                    <div style="font-size: small">
297                        <span style="color: purple">string</span>
298                    </div>
299                </td>
300                <td>
301                </td>
302                <td>
303                        <div>The IP Address to use while sending the ping packet(s).</div>
304                </td>
305            </tr>
306            <tr>
307                <td colspan="2">
308                    <div class="ansibleOptionAnchor" id="parameter-"></div>
309                    <b>state</b>
310                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
311                    <div style="font-size: small">
312                        <span style="color: purple">string</span>
313                    </div>
314                </td>
315                <td>
316                        <ul style="margin: 0; padding: 0"><b>Choices:</b>
317                                    <li>absent</li>
318                                    <li><div style="color: blue"><b>present</b>&nbsp;&larr;</div></li>
319                        </ul>
320                </td>
321                <td>
322                        <div>Determines if the expected result is success or fail.</div>
323                </td>
324            </tr>
325            <tr>
326                <td colspan="2">
327                    <div class="ansibleOptionAnchor" id="parameter-"></div>
328                    <b>ttl</b>
329                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
330                    <div style="font-size: small">
331                        <span style="color: purple">integer</span>
332                    </div>
333                </td>
334                <td>
335                </td>
336                <td>
337                        <div>The time-to-live value for the ICMP packet(s).</div>
338                </td>
339            </tr>
340    </table>
341    <br/>
342
343
344Notes
345-----
346
347.. note::
348   - For a general purpose network module, see the :ref:`ansible.netcommon..net_ping <ansible.netcommon..net_ping_module>` module.
349   - For Windows targets, use the :ref:`ansible.windows.win_ping <ansible.windows.win_ping_module>` module instead.
350   - For targets running Python, use the :ref:`ansible.builtin.ping <ansible.builtin.ping_module>` module instead.
351   - This module works only with connection ``network_cli``.
352   - For information on using CLI and netconf see the :ref:`Junos OS Platform Options guide <junos_platform_options>`
353   - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide <network_guide>`
354   - For more information on using Ansible to manage Juniper network devices see https://www.ansible.com/ansible-juniper.
355
356
357
358Examples
359--------
360
361.. code-block:: yaml
362
363    - name: Test reachability to 10.10.10.10
364      junipernetworks.junos.junos_ping:
365        dest: 10.10.10.10
366
367    - name: Test reachability to 10.20.20.20 using source and size set
368      junipernetworks.junos.junos_ping:
369        dest: 10.20.20.20
370        size: 1024
371        ttl: 128
372
373    - name: Test unreachability to 10.30.30.30 using interval
374      junipernetworks.junos.junos_ping:
375        dest: 10.30.30.30
376        interval: 3
377        state: absent
378
379    - name: Test reachability to 10.40.40.40 setting count and interface
380      junipernetworks.junos.junos_ping:
381        dest: 10.40.40.40
382        interface: fxp0
383        count: 20
384        size: 512
385
386    - name: Test reachability to 10.50.50.50 using do-not-fragment and rapid
387      junipernetworks.junos.junos_ping:
388        dest: 10.50.50.50
389        df_bit: True
390        rapid: True
391
392
393
394Return Values
395-------------
396Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
397
398.. raw:: html
399
400    <table border=0 cellpadding=0 class="documentation-table">
401        <tr>
402            <th colspan="1">Key</th>
403            <th>Returned</th>
404            <th width="100%">Description</th>
405        </tr>
406            <tr>
407                <td colspan="1">
408                    <div class="ansibleOptionAnchor" id="return-"></div>
409                    <b>commands</b>
410                    <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
411                    <div style="font-size: small">
412                      <span style="color: purple">list</span>
413                    </div>
414                </td>
415                <td>always</td>
416                <td>
417                            <div>List of commands sent.</div>
418                    <br/>
419                        <div style="font-size: smaller"><b>Sample:</b></div>
420                        <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[&#x27;ping 10.8.38.44 count 10 source 10.8.38.38 ttl 128&#x27;]</div>
421                </td>
422            </tr>
423            <tr>
424                <td colspan="1">
425                    <div class="ansibleOptionAnchor" id="return-"></div>
426                    <b>packet_loss</b>
427                    <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
428                    <div style="font-size: small">
429                      <span style="color: purple">string</span>
430                    </div>
431                </td>
432                <td>always</td>
433                <td>
434                            <div>Percentage of packets lost.</div>
435                    <br/>
436                        <div style="font-size: smaller"><b>Sample:</b></div>
437                        <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">0%</div>
438                </td>
439            </tr>
440            <tr>
441                <td colspan="1">
442                    <div class="ansibleOptionAnchor" id="return-"></div>
443                    <b>packets_rx</b>
444                    <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
445                    <div style="font-size: small">
446                      <span style="color: purple">integer</span>
447                    </div>
448                </td>
449                <td>always</td>
450                <td>
451                            <div>Packets successfully received.</div>
452                    <br/>
453                        <div style="font-size: smaller"><b>Sample:</b></div>
454                        <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">20</div>
455                </td>
456            </tr>
457            <tr>
458                <td colspan="1">
459                    <div class="ansibleOptionAnchor" id="return-"></div>
460                    <b>packets_tx</b>
461                    <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
462                    <div style="font-size: small">
463                      <span style="color: purple">integer</span>
464                    </div>
465                </td>
466                <td>always</td>
467                <td>
468                            <div>Packets successfully transmitted.</div>
469                    <br/>
470                        <div style="font-size: smaller"><b>Sample:</b></div>
471                        <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">20</div>
472                </td>
473            </tr>
474            <tr>
475                <td colspan="1">
476                    <div class="ansibleOptionAnchor" id="return-"></div>
477                    <b>rtt</b>
478                    <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
479                    <div style="font-size: small">
480                      <span style="color: purple">dictionary</span>
481                    </div>
482                </td>
483                <td>when ping succeeds</td>
484                <td>
485                            <div>The round trip time (RTT) stats.</div>
486                    <br/>
487                        <div style="font-size: smaller"><b>Sample:</b></div>
488                        <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">{&#x27;avg&#x27;: 2, &#x27;max&#x27;: 8, &#x27;min&#x27;: 1, &#x27;stddev&#x27;: 24}</div>
489                </td>
490            </tr>
491    </table>
492    <br/><br/>
493
494
495Status
496------
497
498
499Authors
500~~~~~~~
501
502- Nilashish Chakraborty (@NilashishC)
503