-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathcisco_ios.yml
More file actions
executable file
·136 lines (136 loc) · 5.52 KB
/
cisco_ios.yml
File metadata and controls
executable file
·136 lines (136 loc) · 5.52 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
---
sync_devices:
hostname:
commands:
- command: "show version"
parser: "textfsm"
jpath: "[*].hostname"
serial:
commands:
- command: "show version"
parser: "textfsm"
jpath: "[*].serial[]"
post_processor: "{{ obj | unique | first }}"
iterable_type: "str"
device_type:
commands:
- command: "show version"
parser: "textfsm"
jpath: "[*].hardware[]"
post_processor: "{{ obj | unique | first }}"
iterable_type: "str"
mgmt_interface:
commands:
- command: "show interfaces"
parser: "textfsm"
jpath: "[?ip_address=='{{ obj }}'].{name: interface, enabled: link_status}"
post_processor: "{{ (obj | selectattr('enabled', 'eq', 'up') | list | first ).name }}"
mask_length:
commands:
- command: "show interfaces"
parser: "textfsm"
jpath: "[?ip_address=='{{ obj }}'].prefix_length"
post_processor: "{{ obj | unique | first }}"
iterable_type: "int"
sync_network_data:
pre_processor:
vlan_map:
commands:
- command: "show vlan"
parser: "textfsm"
# Since we use the jdiff custom jmespath we have access to save keys with $ syntax.
jpath: "[*].[$vlan_id$,vlan_name]"
post_processor: "{{ obj | flatten_list_of_dict_from_value('vlan_name') | tojson }}"
serial:
commands:
- command: "show version"
parser: "textfsm"
jpath: "[*].serial[]"
post_processor: "{{ obj | unique | first }}"
iterable_type: "str"
interfaces:
root_key: true
commands:
- command: "show interfaces"
parser: "textfsm"
jpath: "[*].interface" # when root_key=true this extracted value is what becomes interable in keys using __ under `current_key`.
post_processor: "{% set result={} %}{% for interface in obj %}{{ result.update({interface: {}}) or '' }}{% endfor %}{{ result | tojson }}"
interfaces__type:
commands:
- command: "show interfaces"
parser: "textfsm"
jpath: "[?interface=='{{ current_key }}'].hardware_type"
post_processor: "{{ obj[0] | map_interface_type }}"
interfaces__ip_addresses:
commands:
- command: "show interfaces"
parser: "textfsm"
jpath: "[?interface=='{{ current_key }}'].{ip_address: ip_address, prefix_length: prefix_length}"
iterable_type: "list"
interfaces__mtu:
commands:
- command: "show interfaces"
parser: "textfsm"
jpath: "[?interface=='{{ current_key }}'].mtu"
iterable_type: "str"
interfaces__mac_address:
commands:
- command: "show interfaces"
parser: "textfsm"
jpath: "[?interface=='{{ current_key }}'].mac_address"
interfaces__description:
commands:
- command: "show interfaces"
parser: "textfsm"
jpath: "[?interface=='{{ current_key }}'].description"
interfaces__link_status:
commands:
- command: "show interfaces"
parser: "textfsm"
jpath: "[?interface=='{{ current_key }}'].link_status"
post_processor: "{{ obj[0] | cisco_interface_status_to_bool }}"
interfaces__802.1Q_mode:
commands:
- command: "show interfaces switchport"
parser: "textfsm"
jpath: "[?interface=='{{ current_key | abbreviated_interface_name }}'].{admin_mode: admin_mode, mode: mode, trunking_vlans: trunking_vlans}"
post_processor: "{{ obj | interface_mode_logic }}"
iterable_type: "str"
interfaces__lag:
commands:
- command: "show etherchannel summary"
parser: "textfsm"
jpath: "[?contains(@.member_interface, `{{ current_key | abbreviated_interface_name }}`)].bundle_name"
post_processor: "{% if obj | length > 0 %}{{ obj[0] | canonical_interface_name }}{% else %}{{ obj }}{% endif %}"
iterable_type: "str"
interfaces__vrf:
commands:
- command: "show ip interface"
parser: "textfsm"
jpath: "[?interface=='{{ current_key }}'].{name:vrf}"
post_processor: "{% if obj | length > 0 %}{{ obj[0] | key_exist_or_default('name') | tojson }}{% else %}{{ obj }}{% endif %}"
iterable_type: "dict"
interfaces__tagged_vlans:
commands:
- command: "show interfaces switchport"
parser: "textfsm"
jpath: "[?interface=='{{ current_key | abbreviated_interface_name }}'].{admin_mode: admin_mode, mode: mode, access_vlan: access_vlan, trunking_vlans: trunking_vlans, native_vlan: native_vlan}"
post_processor: "{{ obj | get_vlan_data(vlan_map, 'tagged') | tojson }}"
interfaces__untagged_vlan:
commands:
- command: "show interfaces switchport"
parser: "textfsm"
jpath: "[?interface=='{{ current_key | abbreviated_interface_name }}'].{admin_mode: admin_mode, mode: mode, access_vlan: access_vlan, trunking_vlans: trunking_vlans, native_vlan: native_vlan}"
post_processor: "{{ obj | get_vlan_data(vlan_map, 'untagged') | tojson }}"
iterable_type: "dict"
cables:
commands:
- command: "show cdp neighbors detail"
parser: "textfsm"
jpath: "[*].{local_interface:local_interface, remote_interface:neighbor_interface, remote_device:neighbor_name}"
post_processor: "{% set result = [] %}{% for cable in obj %}{% set _=result.append({'local_interface': cable['local_interface'], 'remote_interface': cable['remote_interface'], 'remote_device': cable['remote_device'] | remove_fqdn }) %}{% endfor %}{{ result | tojson }}"
software_version:
commands:
- command: "show version"
parser: "textfsm"
jpath: "[*].version"