Adding Netbox

This commit is contained in:
Patrick Toal
2019-05-06 00:34:45 -04:00
parent 832502de34
commit 6e2205a046
278 changed files with 12767 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
---
parser_path: "{{ role_path }}/parser_templates/{{ ansible_network_os }}"
output_path: "{{ role_path }}/output/{{ ansible_network_os }}"
export_type: "list"

View File

@@ -0,0 +1,85 @@
GigabitEthernet0/0 is up, line protocol is up
Hardware is iGbE, address is 5e00.0002.0000 (bia 5e00.0002.0000)
Description: OOB Management
Internet address is 10.8.38.65/24
MTU 1500 bytes, BW 1000000 Kbit/sec, DLY 10 usec,
reliability 253/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
Keepalive set (10 sec)
Full Duplex, Auto Speed, link type is auto, media type is RJ45
output flow-control is unsupported, input flow-control is unsupported
ARP type: ARPA, ARP Timeout 04:00:00
Last input 00:00:00, output 00:00:00, output hang never
Last clearing of "show interface" counters never
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: fifo
Output queue: 0/40 (size/max)
5 minute input rate 2000 bits/sec, 2 packets/sec
5 minute output rate 2000 bits/sec, 2 packets/sec
4973387 packets input, 816226566 bytes, 0 no buffer
Received 228869 broadcasts (0 IP multicasts)
461509 runts, 0 giants, 0 throttles
461509 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
0 watchdog, 0 multicast, 0 pause input
3316083 packets output, 432440225 bytes, 0 underruns
0 output errors, 0 collisions, 3 interface resets
2303378 unknown protocol drops
0 babbles, 0 late collision, 0 deferred
1 lost carrier, 0 no carrier, 0 pause output
0 output buffer failures, 0 output buffers swapped out
GigabitEthernet0/1 is up, line protocol is up
Hardware is iGbE, address is fa16.3e4e.c5e5 (bia fa16.3e4e.c5e5)
Description: test-interface
MTU 2000 bytes, BW 1000000 Kbit/sec, DLY 10 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
Keepalive set (10 sec)
Full Duplex, 1Gbps, link type is auto, media type is RJ45
output flow-control is unsupported, input flow-control is unsupported
ARP type: ARPA, ARP Timeout 04:00:00
Last input 4d07h, output 4d07h, output hang never
Last clearing of "show interface" counters never
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: fifo
Output queue: 0/40 (size/max)
5 minute input rate 0 bits/sec, 0 packets/sec
5 minute output rate 0 bits/sec, 0 packets/sec
89815 packets input, 27598643 bytes, 0 no buffer
Received 1 broadcasts (0 IP multicasts)
0 runts, 0 giants, 0 throttles
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
0 watchdog, 0 multicast, 0 pause input
404016 packets output, 27896846 bytes, 0 underruns
0 output errors, 0 collisions, 51 interface resets
89728 unknown protocol drops
0 babbles, 0 late collision, 0 deferred
28 lost carrier, 0 no carrier, 0 pause output
0 output buffer failures, 0 output buffers swapped out
GigabitEthernet0/2 is up, line protocol is up
Hardware is iGbE, address is fa16.3eca.c938 (bia fa16.3eca.c938)
Description: test-interface-2
MTU 2000 bytes, BW 1000000 Kbit/sec, DLY 10 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
Keepalive set (10 sec)
Full Duplex, 1Gbps, link type is auto, media type is RJ45
output flow-control is unsupported, input flow-control is unsupported
ARP type: ARPA, ARP Timeout 04:00:00
Last input 3w1d, output 00:00:08, output hang never
Last clearing of "show interface" counters never
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: fifo
Output queue: 0/40 (size/max)
5 minute input rate 0 bits/sec, 0 packets/sec
5 minute output rate 0 bits/sec, 0 packets/sec
487240 packets input, 36339153 bytes, 0 no buffer
Received 8 broadcasts (0 IP multicasts)
183253 runts, 0 giants, 0 throttles
183253 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
0 watchdog, 0 multicast, 0 pause input
1115575 packets output, 73936479 bytes, 0 underruns
0 output errors, 0 collisions, 12 interface resets
0 unknown protocol drops
0 babbles, 0 late collision, 0 deferred
5 lost carrier, 0 no carrier, 0 pause output
0 output buffer failures, 0 output buffers swapped out

View File

@@ -0,0 +1,44 @@
Cisco IOS Software, IOSv Software (VIOS-ADVENTERPRISEK9-M), Version 15.6(2)T, RELEASE SOFTWARE (fc2)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2016 by Cisco Systems, Inc.
Compiled Tue 22-Mar-16 16:19 by prod_rel_team
ROM: Bootstrap program is IOSv
an-ios-01 uptime is 10 weeks, 6 days, 22 hours, 30 minutes
System returned to ROM by reload
System image file is "flash0:/vios-adventerprisek9-m"
Last reload reason: Unknown reason
This product contains cryptographic features and is subject to United
States and local country laws governing import, export, transfer and
use. Delivery of Cisco cryptographic products does not imply
third-party authority to import, export, distribute or use encryption.
Importers, exporters, distributors and users are responsible for
compliance with U.S. and local country laws. By using this product you
agree to comply with applicable laws and regulations. If you are unable
to comply with U.S. and local laws, return this product immediately.
A summary of U.S. laws governing Cisco cryptographic products may be found at:
http://www.cisco.com/wwl/export/crypto/tool/stqrg.html
If you require further assistance please contact us by sending email to
export@cisco.com.
Cisco IOSv (revision 1.0) with with 460033K/62464K bytes of memory.
Processor board ID 92O0KON393UV5P77JRKZ5
4 Gigabit Ethernet interfaces
DRAM configuration is 72 bits wide with parity disabled.
256K bytes of non-volatile configuration memory.
2097152K bytes of ATA System CompactFlash 0 (Read/Write)
0K bytes of ATA CompactFlash 1 (Read/Write)
0K bytes of ATA CompactFlash 2 (Read/Write)
10080K bytes of ATA CompactFlash 3 (Read/Write)
Configuration register is 0x0

View File

@@ -0,0 +1,61 @@
---
- name: parser meta data
parser_metadata:
version: 1.0
command: show interface
network_os: ios
- name: match sections
pattern_match:
regex: "^(\\S+) is up,"
match_all: true
match_greedy: true
register: section
- name: match interface values
pattern_group:
- name: match name
pattern_match:
regex: "^(\\S+)"
content: "{{ item }}"
register: name
- name: match hardware
pattern_match:
regex: "Hardware is (\\S+),"
content: "{{ item }}"
register: type
- name: match mtu
pattern_match:
regex: "MTU (\\d+)"
content: "{{ item }}"
register: mtu
- name: match description
pattern_match:
regex: "Description: (.*)"
content: "{{ item }}"
register: description
loop: "{{ section }}"
register: interfaces
- name: generate json data structure
json_template:
template:
- key: "{{ item.name.matches.0 }}"
object:
- key: config
object:
- key: name
value: "{{ item.name.matches.0 }}"
- key: type
value: "{{ item.type.matches.0 }}"
- key: mtu
value: "{{ item.mtu.matches.0 }}"
- key: description
value: "{{ item.description.matches.0 }}"
loop: "{{ interfaces }}"
export: true
export_as: "{{ export_type }}"
register: interface_facts

View File

@@ -0,0 +1,61 @@
---
- name: parser meta data
parser_metadata:
version: 1.0
command: show interface
network_os: ios
- name: match sections
pattern_match:
regex: "^(\\S+) is up,"
match_all: true
match_greedy: true
register: section
- name: match interface values
pattern_group:
- name: match name
pattern_match:
regex: "^(\\S+)"
content: "{{ item }}"
register: name
- name: match hardware
pattern_match:
regex: "Hardware is (\\S+),"
content: "{{ item }}"
register: type
- name: match mtu
pattern_match:
regex: "MTU (\\d+)"
content: "{{ item }}"
register: mtu
- name: match description
pattern_match:
regex: "Description: (.*)"
content: "{{ item }}"
register: description
loop: "{{ section }}"
register: interfaces
- name: generate json data structure
json_template:
template:
- key: "{{ item.name.matches.0 }}"
object:
- key: config
object:
- key: name
value: "{{ item.name.matches.0 }}"
- key: type
value: "{{ item.type.matches.0 }}"
- key: mtu
value: "{{ item.mtu.matches.0 }}"
- key: description
value: "{{ item.description.matches.0 }}"
loop: "{{ interfaces }}"
export: true
register: interface_facts
extend: test.extension

View File

@@ -0,0 +1,48 @@
---
- name: parser meta data
parser_metadata:
version: 1.0
command: show version
network_os: ios
- name: match version
pattern_match:
regex: "Version (\\S+),"
register: version
- name: match model
pattern_match:
regex: "^Cisco (.+) \\(revision"
register: model
- name: match image
pattern_match:
regex: "^System image file is (\\S+)"
register: image
- name: match uptime
pattern_match:
regex: "uptime is (.+)"
register: uptime
- name: match total memory
pattern_match:
regex: "with (\\S+)/(\\w*) bytes of memory"
register: total_mem
- name: match free memory
pattern_match:
regex: "with \\w*/(\\S+) bytes of memory"
register: free_mem
- name: export system facts to playbook
set_vars:
model: "{{ model.matches.0 }}"
image_file: "{{ image.matches.0 }}"
uptime: "{{ uptime.matches.0 }}"
version: "{{ version.matches.0 }}"
memory:
total: "{{ total_mem.matches.0 }}"
free: "{{ free_mem.matches.0 }}"
export: true
register: system_facts

View File

@@ -0,0 +1,49 @@
---
- name: parser meta data
parser_metadata:
version: 1.0
command: show version
network_os: ios
- name: match version
pattern_match:
regex: "Version (\\S+),"
register: version
- name: match model
pattern_match:
regex: "^Cisco (.+) \\(revision"
register: model
- name: match image
pattern_match:
regex: "^System image file is (\\S+)"
register: image
- name: match uptime
pattern_match:
regex: "uptime is (.+)"
register: uptime
- name: match total memory
pattern_match:
regex: "with (\\S+)/(\\w*) bytes of memory"
register: total_mem
- name: match free memory
pattern_match:
regex: "with \\w*/(\\S+) bytes of memory"
register: free_mem
- name: export system facts to playbook
set_vars:
model: "{{ model.matches.0 }}"
image_file: "{{ image.matches.0 }}"
uptime: "{{ uptime.matches.0 }}"
version: "{{ version.matches.0 }}"
memory:
total: "{{ total_mem.matches.0 }}"
free: "{{ free_mem.matches.0 }}"
export: true
register: system_facts
extend: test.extension

View File

@@ -0,0 +1,79 @@
---
- name: "command_parser test for {{ ansible_network_os }} show_interface"
command_parser:
file: "{{ parser_path }}/show_interfaces.yaml"
content: "{{ lookup('file', '{{ output_path }}/show_interfaces.txt') }}"
register: result
vars:
- ansible_network_os: ios
- assert:
that:
- "'interface_facts' in result.ansible_facts"
- "'GigabitEthernet0/0' in result.ansible_facts.interface_facts[0]"
- "'GigabitEthernet0/1' in result.ansible_facts.interface_facts[1]"
- "result.ansible_facts.interface_facts[0]['GigabitEthernet0/0']['config']['name'] == 'GigabitEthernet0/0'"
- "result.ansible_facts.interface_facts[0]['GigabitEthernet0/0']['config']['description'] == 'OOB Management'"
- "result.ansible_facts.interface_facts[1]['GigabitEthernet0/1']['config']['name'] == 'GigabitEthernet0/1'"
- "result.ansible_facts.interface_facts[1]['GigabitEthernet0/1']['config']['description'] == 'test-interface'"
- name: "command_parser test for {{ ansible_network_os }} show_version"
command_parser:
file: "{{ parser_path }}/show_version.yaml"
content: "{{ lookup('file', '{{ output_path }}/show_version.txt') }}"
register: result
vars:
- ansible_network_os: ios
- assert:
that:
- "'system_facts' in result.ansible_facts"
- "'flash0:/vios-adventerprisek9-m' in result.ansible_facts.system_facts['image_file']"
- "'IOSv' in result.ansible_facts.system_facts['model']"
- "'15.6(2)T' in result.ansible_facts.system_facts['version']"
- "'10 weeks, 6 days, 22 hours, 30 minutes' in result.ansible_facts.system_facts['uptime']"
- "'62464K' in result.ansible_facts.system_facts['memory']['free']"
- "'460033K' in result.ansible_facts.system_facts['memory']['total']"
- name: "command_parser expansion test for {{ ansible_network_os }} show_version"
command_parser:
file: "{{ parser_path }}/show_version_expand.yaml"
content: "{{ lookup('file', '{{ output_path }}/show_version.txt') }}"
register: result
vars:
- ansible_network_os: ios
- assert:
that:
- "'system_facts' in result.ansible_facts.test.extension"
- "'flash0:/vios-adventerprisek9-m' in result.ansible_facts.test.extension.system_facts['image_file']"
- "'IOSv' in result.ansible_facts.test.extension.system_facts['model']"
- "'15.6(2)T' in result.ansible_facts.test.extension.system_facts['version']"
- "'10 weeks, 6 days, 22 hours, 30 minutes' in result.ansible_facts.test.extension.system_facts['uptime']"
- "'62464K' in result.ansible_facts.test.extension.system_facts['memory']['free']"
- "'460033K' in result.ansible_facts.test.extension.system_facts['memory']['total']"
- name: "command_parser expansion test for {{ ansible_network_os }} show_interface"
command_parser:
file: "{{ parser_path }}/show_interfaces_expand.yaml"
content: "{{ lookup('file', '{{ output_path }}/show_interfaces.txt') }}"
register: result
vars:
- ansible_network_os: ios
- assert:
that:
- "'system_facts' in result.ansible_facts.test.extension"
- "'flash0:/vios-adventerprisek9-m' in result.ansible_facts.test.extension.system_facts['image_file']"
- "'IOSv' in result.ansible_facts.test.extension.system_facts['model']"
- "'15.6(2)T' in result.ansible_facts.test.extension.system_facts['version']"
- "'10 weeks, 6 days, 22 hours, 30 minutes' in result.ansible_facts.test.extension.system_facts['uptime']"
- "'62464K' in result.ansible_facts.test.extension.system_facts['memory']['free']"
- "'460033K' in result.ansible_facts.test.extension.system_facts['memory']['total']"
- "'interface_facts' in result.ansible_facts.test.extension"
- "'GigabitEthernet0/0' in result.ansible_facts.test.extension.interface_facts[0]"
- "'GigabitEthernet0/1' in result.ansible_facts.test.extension.interface_facts[1]"
- "result.ansible_facts.test.extension.interface_facts[0]['GigabitEthernet0/0']['config']['name'] == 'GigabitEthernet0/0'"
- "result.ansible_facts.test.extension.interface_facts[0]['GigabitEthernet0/0']['config']['description'] == 'OOB Management'"
- "result.ansible_facts.test.extension.interface_facts[1]['GigabitEthernet0/1']['config']['name'] == 'GigabitEthernet0/1'"
- "result.ansible_facts.test.extension.interface_facts[1]['GigabitEthernet0/1']['config']['description'] == 'test-interface'"

View File

@@ -0,0 +1,7 @@
---
- name: import dependency role for test
import_role:
name: "{{ role_path.split('/tests/command_parser/command_parser')[0] }}"
- name: ios command_parser test
import_tasks: ios.yaml

View File

@@ -0,0 +1,5 @@
---
- hosts: localhost
connection: local
roles:
- command_parser