-
Notifications
You must be signed in to change notification settings - Fork 2
/
ping.yml
51 lines (38 loc) · 1.2 KB
/
ping.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
# This is a playbook for Ansible using network-engine with "ping" parser.
# Example: ansible-playbook ping.yml --extra-vars dst=192.168.0.1
# Example: ansible-playbook ping.yml --limit switch.example.com --extra-vars dst="192.168.0.1 vrf=100"
- hosts: unknown
vars:
vrf: ""
roles:
- ansible-network.network-engine
tasks:
- name: Run 'ping'
ios_command:
commands:
- ping "{{ dst }}"
register: output
when: vrf is not defined
- name: Run 'ping with vrf'
ios_command:
commands:
- ping vrf "{{ vrf }}" "{{ dst }}"
register: output
when: vrf is defined
# - name: Display the output
# debug: var=output.stdout
- name: Parse the output
command_parser:
file: "parsers/ios/ping_parser.yml"
content: "{{ output.stdout[0] }}"
- name: Display the data
debug: var=ping_facts
- name: Delete '/tmp/ping_facts-[inventory_hostname].json'
file:
path: "/tmp/ping_facts-{{ inventory_hostname }}.json"
state: absent
- name: Write ping_facts to '/tmp/ping_facts-[inventory_hostname].json'
copy:
content: "{{ ping_facts | to_nice_json }}"
dest: "/tmp/ping_facts-{{ inventory_hostname }}.json"