-
Notifications
You must be signed in to change notification settings - Fork 0
/
show_ip_vrf_interface.yml
92 lines (70 loc) · 3.46 KB
/
show_ip_vrf_interface.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
- hosts: ios-devices
# This is a playbook for Ansible using network-engine with "show ip vrf interface" parser.
#
# The output of "show ip vrf interface" is shortening all the interface names.
# This playbook renames the interfaces to the longer complete names in the output files.
roles:
- ansible-network.network-engine
tasks:
- name: run show ip vrf interface
ios_command:
commands:
- show ip vrf interface
register: output
# - name: Display the output
# debug: var=output.stdout
- name: Parse the output
command_parser:
file: "parsers/ios/show_ip_vrf_interface_parser.yml"
content: "{{ output.stdout[0] }}"
# - name: Display the data
# debug: var=ip_vrf_interface_facts
- name: Delete '/tmp/ip_vrf_interface_facts-[inventory_hostname].json'
file:
path: "/tmp/ip_vrf_interface_facts-{{ inventory_hostname }}.json"
state: absent
- name: Write ip_vrf_interface_facts to '/tmp/ip_vrf_interface_facts-[inventory_hostname].json'
copy:
content: "{{ ip_vrf_interface_facts | to_nice_json }}"
dest: "/tmp/ip_vrf_interface_facts-{{ inventory_hostname }}.json"
# Replacing short interface names with the full name.
- name: Replace short interface name Loopback with long names in '/tmp/ip_vrf_interface_facts-[inventory_hostname].json'
replace:
path: "/tmp/ip_vrf_interface_facts-{{ inventory_hostname }}.json"
regexp: '"name": "Lo(?=[0-9])'
replace: '"name": "Loopback'
- name: Replace short interface name Vlan with long names in '/tmp/ip_vrf_interface_facts-[inventory_hostname].json'
replace:
path: "/tmp/ip_vrf_interface_facts-{{ inventory_hostname }}.json"
regexp: '"name": "Vl(?=[0-9])'
replace: '"name": "Vlan'
- name: Replace short interface name FastEthernet with long names in '/tmp/ip_vrf_interface_facts-[inventory_hostname].json'
replace:
path: "/tmp/ip_vrf_interface_facts-{{ inventory_hostname }}.json"
regexp: '"name": "Fa(?=[0-9])'
replace: '"name": "FastEthernet'
- name: Replace short interface name GigabitEthernet with long names in '/tmp/ip_vrf_interface_facts-[inventory_hostname].json'
replace:
path: "/tmp/ip_vrf_interface_facts-{{ inventory_hostname }}.json"
regexp: '"name": "Gi(?=[0-9])'
replace: '"name": "GigabitEthernet'
- name: Replace short interface name TenGigabitEthernet with long names in '/tmp/ip_vrf_interface_facts-[inventory_hostname].json'
replace:
path: "/tmp/ip_vrf_interface_facts-{{ inventory_hostname }}.json"
regexp: '"name": "Te(?=[0-9])'
replace: '"name": "TenGigabitEthernet'
- name: Replace short interface name FortyGigabitEthernet with long names in '/tmp/ip_vrf_interface_facts-[inventory_hostname].json'
replace:
path: "/tmp/ip_vrf_interface_facts-{{ inventory_hostname }}.json"
regexp: '"name": "Fo(?=[0-9])'
replace: '"name": "FortyGigabitEthernet'
- name: Replace short interface name Port-channel with long names in '/tmp/ip_vrf_interface_facts-[inventory_hostname].json'
replace:
path: "/tmp/ip_vrf_interface_facts-{{ inventory_hostname }}.json"
regexp: '"name": "Po(?=[0-9])'
replace: '"name": "Port-channel'
- name: Replace short interface name Async with long names in '/tmp/ip_vrf_interface_facts-[inventory_hostname].json'
replace:
path: "/tmp/ip_vrf_interface_facts-{{ inventory_hostname }}.json"
regexp: '"name": "As(?=[0-9])'
replace: '"name": "Async'