Adding Netbox
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
---
|
||||
- name: parser meta data
|
||||
parser_metadata:
|
||||
version: 1.0
|
||||
command: show cdp neighbors detail
|
||||
network_os: ios
|
||||
|
||||
- name: match sections
|
||||
pattern_match:
|
||||
regex: "^-----.*"
|
||||
match_all: true
|
||||
match_greedy: true
|
||||
register: context
|
||||
|
||||
- name: parse cdp neighbors
|
||||
pattern_group:
|
||||
- name: parse local port
|
||||
pattern_match:
|
||||
regex: '^Interface: ([^,]*)'
|
||||
content: "{{ item }}"
|
||||
register: local_port
|
||||
|
||||
- name: parse remote prort
|
||||
pattern_match:
|
||||
regex: 'Port ID \(outgoing port\): (.*)$'
|
||||
content: "{{ item }}"
|
||||
register: remote_port
|
||||
|
||||
- name: parse remote host
|
||||
pattern_match:
|
||||
regex: 'Device ID: (.*)$'
|
||||
content: "{{ item }}"
|
||||
register: remote_host
|
||||
|
||||
loop: "{{ context }}"
|
||||
register: matches
|
||||
|
||||
- name: build cdp neighbor facts
|
||||
loop: "{{ matches }}"
|
||||
register: cdp
|
||||
export: true
|
||||
export_as: dict
|
||||
extend: "{{ toplevel | default('cisco_ios') }}"
|
||||
json_template:
|
||||
template:
|
||||
- key: "{{ item.local_port.matches.0 | expand_interface_name }}"
|
||||
object:
|
||||
- key: neighbor
|
||||
value: "{{ item.remote_host.matches.0 }}"
|
||||
- key: neighbor_port
|
||||
value: "{{ item.remote_port.matches.0 }}"
|
||||
@@ -0,0 +1,119 @@
|
||||
---
|
||||
- name: parser meta data
|
||||
parser_metadata:
|
||||
version: 1.0
|
||||
command: show interfaces
|
||||
network_os: ios
|
||||
|
||||
- name: match sections
|
||||
pattern_match:
|
||||
regex: "^\\S+ is (up|down|administratively down),"
|
||||
match_all: true
|
||||
match_greedy: true
|
||||
register: context
|
||||
|
||||
- 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 (.*(?=,)|.*)"
|
||||
content: "{{ item }}"
|
||||
register: type
|
||||
|
||||
- name: match mtu
|
||||
pattern_match:
|
||||
regex: "MTU (\\d+)"
|
||||
content: "{{ item }}"
|
||||
register: mtu
|
||||
|
||||
- name: match interface description
|
||||
pattern_match:
|
||||
regex: "Description: (.+)"
|
||||
content: "{{ item }}"
|
||||
register: description
|
||||
|
||||
- name: match administrative state
|
||||
pattern_match:
|
||||
regex: "(administratively down)"
|
||||
content: "{{ item }}"
|
||||
register: enabled
|
||||
|
||||
- name: match line protocol
|
||||
pattern_match:
|
||||
regex: "line protocol is (\\S+)"
|
||||
content: "{{ item }}"
|
||||
register: operstatus
|
||||
|
||||
- name: match in packets
|
||||
pattern_match:
|
||||
regex: "(\\d+) packets input, (\\d+)"
|
||||
content: "{{ item }}"
|
||||
register: in_pkts_octets
|
||||
|
||||
- name: match input broadcast
|
||||
pattern_match:
|
||||
regex: "Received (\\d+) broadcasts \\(\\d+"
|
||||
content: "{{ item }}"
|
||||
register: in_bcast_mcast
|
||||
|
||||
- name: match out packets
|
||||
pattern_match:
|
||||
regex: "(\\d+) packets output, (\\d+) bytes"
|
||||
content: "{{ item }}"
|
||||
register: out_pkts_octets
|
||||
|
||||
- name: match out errors
|
||||
pattern_match:
|
||||
regex: "(\\d+) output errors"
|
||||
content: "{{ item }}"
|
||||
register: out_errors
|
||||
|
||||
loop: "{{ context }}"
|
||||
register: values
|
||||
|
||||
- name: template interface values
|
||||
loop: "{{ values }}"
|
||||
register: interfaces
|
||||
export: true
|
||||
export_as: dict
|
||||
extend: cisco_ios
|
||||
json_template:
|
||||
template:
|
||||
- key: "{{ item.name.matches.0 }}"
|
||||
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 }}"
|
||||
- key: enabled
|
||||
value: "{{ item.enabled.matches.0 is undefined }}"
|
||||
- key: admin-status
|
||||
value: "{{ item.enabled.matches.0 is undefined | ternary ('enabled', 'disabled') }}"
|
||||
- key: oper-status
|
||||
value: "{{ item.operstatus.matches.0 }}"
|
||||
- key: counters
|
||||
object:
|
||||
- key: in-octets
|
||||
value: "{{ item.in_pkts_octets.matches.0 }}"
|
||||
- key: in-unicast-pkts
|
||||
value: "{{ item.in_pkts_octets.matches.1 }}"
|
||||
- key: in-broadcast-pkts
|
||||
value: "{{ item.in_bcast_mcast.matches.0 }}"
|
||||
- key: in-multicast-pkts
|
||||
value: "{{ item.in_bcast_mcast.matches.1 }}"
|
||||
- key: out-octets
|
||||
value: "{{ item.out_pkts_octets.matches.0 }}"
|
||||
- key: out-unicast-pkts
|
||||
value: "{{ item.out_pkts_octets.matches.1 }}"
|
||||
- key: out-errors
|
||||
value: "{{ item.out_errors.matches.0 }}"
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
- name: parser meta data
|
||||
parser_metadata:
|
||||
version: 1.0
|
||||
command: show interfaces transceiver
|
||||
network_os: ios
|
||||
|
||||
- name: match sections
|
||||
pattern_match:
|
||||
regex: '(^\S{2}\d+/\d/\d+).*'
|
||||
match_all: true
|
||||
match_greedy: true
|
||||
register: context
|
||||
|
||||
- name: match interface transceiver
|
||||
pattern_group:
|
||||
- name: match transceiver
|
||||
pattern_match:
|
||||
regex: '(^\S{2}\d+/\d/\d+)'
|
||||
content: "{{ item }}"
|
||||
register: transceiver
|
||||
|
||||
- name: match temperature
|
||||
pattern_match:
|
||||
regex: '(^\S{2}\d+/\d/\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)*\s*(-?\d+\.\d+)\s*(-?\d+\.\d+)*\s*([-\+]*)$'
|
||||
content: "{{ item }}"
|
||||
register: temperature
|
||||
|
||||
- name: match voltage
|
||||
pattern_match:
|
||||
regex: '(^\S{2}\d+/\d/\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)*\s*(-?\d+\.\d+)\s*(-?\d+\.\d+)*\s*([-\+]*)$'
|
||||
content: "{{ item }}"
|
||||
register: voltage
|
||||
|
||||
- name: match TxPower
|
||||
pattern_match:
|
||||
regex: '(^\S{2}\d+/\d/\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)*\s*(-?\d+\.\d+)\s*(-?\d+\.\d+)*\s*([-\+]*)$'
|
||||
content: "{{ item }}"
|
||||
register: txpower
|
||||
|
||||
- name: match RxPower
|
||||
pattern_match:
|
||||
regex: '(^\S{2}\d+/\d/\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)*\s*(-?\d+\.\d+)\s*(-?\d+\.\d+)*\s*([-\+]*)$'
|
||||
content: "{{ item }}"
|
||||
register: rxpower
|
||||
|
||||
- name: match Alarm
|
||||
pattern_match:
|
||||
regex: '(^\S{2}\d+/\d/\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)*\s*(-?\d+\.\d+)\s*(-?\d+\.\d+)*\s*([-\+]*)$'
|
||||
content: "{{ item }}"
|
||||
register: alarm
|
||||
|
||||
loop: "{{ context }}"
|
||||
register: values
|
||||
|
||||
- name: template interface values
|
||||
loop: "{{ values }}"
|
||||
register: transceiver
|
||||
export: true
|
||||
export_as: dict
|
||||
extend: cisco_ios
|
||||
json_template:
|
||||
template:
|
||||
- key: "{{ item.transceiver.matches.0 | expand_interface_name}}"
|
||||
object:
|
||||
- key: temperature
|
||||
value: "{{ item.temperature.matches.1 }}"
|
||||
- key: voltage
|
||||
value: "{{ item.voltage.matches.2 }}"
|
||||
- key: tx
|
||||
value: "{{ item.txpower.matches.4 }}"
|
||||
- key: rx
|
||||
value: "{{ item.rxpower.matches.5 }}"
|
||||
- key: alarm
|
||||
value: "{{ item.rxpower.matches.6 }}"
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
|
||||
- name: show_ip_bgp_summary
|
||||
parser_metadata:
|
||||
version: 1.0
|
||||
command: show ip bgp summary
|
||||
network_os: ios
|
||||
|
||||
- name: match not active
|
||||
register: not_active
|
||||
pattern_match:
|
||||
regex: "BGP not active"
|
||||
match_all: true
|
||||
|
||||
- name: set_vars bgp state active
|
||||
set_vars:
|
||||
process_state: "active"
|
||||
|
||||
- name: set_vars bgp state not active
|
||||
set_vars:
|
||||
process_state: "not active"
|
||||
when: "not_active.0.matches == 'BGP not active'"
|
||||
|
||||
- name: match sections
|
||||
register: context
|
||||
pattern_match:
|
||||
regex: "Neighbor.+"
|
||||
match_all: true
|
||||
match_greedy: true
|
||||
when: process_state == 'active'
|
||||
|
||||
- name: match lines
|
||||
register: lines
|
||||
pattern_match:
|
||||
regex: "^[0-9a-f.]+"
|
||||
content: "{{ context.0 }}"
|
||||
match_all: true
|
||||
match_greedy: true
|
||||
when: process_state == 'active'
|
||||
|
||||
- name: match neighbors
|
||||
register: matched_neighbors
|
||||
loop: "{{ lines }}"
|
||||
pattern_match:
|
||||
regex: "(?P<ip>[0-9a-f.]+)\\s+(?P<version>\\d+)\\s+(?P<asn>\\d+)\\s+(?P<msgrcvd>\\d+)\\s+(?P<msgsent>\\d+)\\s+(?P<tblver>\\d+)\\s+(?P<inq>\\d+)\\s+(?P<outq>\\d+)\\s+(?P<timer>\\S+)\\s+(?P<state>\\S+)"
|
||||
content: "{{ item }}"
|
||||
when: process_state == 'active'
|
||||
|
||||
- name: template bgp values
|
||||
extend: cisco_ios.vrf.DEFAULT.protocols
|
||||
register: bgp
|
||||
export: true
|
||||
export_as: dict
|
||||
json_template:
|
||||
template:
|
||||
- key: "process_state"
|
||||
value: "{{ process_state }}"
|
||||
|
||||
- name: template bgp neighbor entries
|
||||
extend: cisco_ios.vrf.DEFAULT.protocols.bgp
|
||||
register: neighbors
|
||||
export: true
|
||||
export_as: dict
|
||||
loop: "{{ matched_neighbors }}"
|
||||
when: process_state == 'active'
|
||||
json_template:
|
||||
template:
|
||||
- key: "{{ item.ip }}"
|
||||
object:
|
||||
- key: state_pfxrcd
|
||||
value: "{{ item.state }}"
|
||||
- key: asn
|
||||
value: "{{ item.asn }}"
|
||||
- key: timer
|
||||
value: "{{ item.timer }}"
|
||||
- key: ip_version
|
||||
value: "{{ item.version }}"
|
||||
@@ -0,0 +1,138 @@
|
||||
---
|
||||
|
||||
- name: show_ip_vrf_detail
|
||||
parser_metadata:
|
||||
version: 1.0
|
||||
command: show ip vrf detail
|
||||
network_os: ios
|
||||
|
||||
- name: match vrf sections
|
||||
register: vrf_section
|
||||
pattern_match:
|
||||
regex: "^VRF \\S+(?: \\(VRF Id = \\d+\\)|); default RD"
|
||||
match_all: true
|
||||
match_greedy: true
|
||||
|
||||
- name: match vrf section values
|
||||
loop: "{{ vrf_section }}"
|
||||
register: vrf_section_values
|
||||
pattern_group:
|
||||
|
||||
- name: match name
|
||||
pattern_match:
|
||||
regex: "^VRF (\\S+)(?: \\(VRF Id = \\d+\\)|); default RD"
|
||||
content: "{{ item }}"
|
||||
register: name
|
||||
|
||||
- name: match description
|
||||
pattern_match:
|
||||
regex: "^ Description: (.*)"
|
||||
content: "{{ item }}"
|
||||
register: description
|
||||
|
||||
- name: match route distinguisher
|
||||
pattern_match:
|
||||
regex: ".*; default RD (\\d+:\\d+|<not set>)"
|
||||
content: "{{ item }}"
|
||||
register: rd
|
||||
|
||||
- name: match interface section
|
||||
pattern_match:
|
||||
regex: "^ Interfaces:([\\s\\S]*)(?:Address family|VRF Table ID)"
|
||||
content: "{{ item }}"
|
||||
match_all: true
|
||||
match_greedy: false
|
||||
register: interface_section
|
||||
|
||||
- name: match export route target section
|
||||
pattern_match:
|
||||
regex: "(?:No|)Export VPN route-target communities([\\s\\S]*) (?:No |)Import VPN"
|
||||
content: "{{ item }}"
|
||||
match_all: true
|
||||
match_greedy: false
|
||||
register: export_rt_section
|
||||
|
||||
- name: match import route target section
|
||||
pattern_match:
|
||||
regex: "Import VPN route-target communities([\\s\\S]*) (?:No |)import"
|
||||
content: "{{ item }}"
|
||||
match_all: true
|
||||
match_greedy: false
|
||||
register: import_rt_section
|
||||
|
||||
- name: match vrf nested section values
|
||||
loop: "{{ vrf_section_values }}"
|
||||
register: vrf_nested_section_values
|
||||
loop_control:
|
||||
loop_var: vrf_item
|
||||
pattern_group:
|
||||
|
||||
- name: match vrf name
|
||||
pattern_match:
|
||||
regex: "(.*)"
|
||||
content: "{{ vrf_item.name.matches.0 }}"
|
||||
register: name
|
||||
|
||||
- name: match description
|
||||
pattern_match:
|
||||
regex: "(.*)"
|
||||
content: "{{ vrf_item.description.matches.0 }}"
|
||||
register: description
|
||||
|
||||
- name: match route distinguisher
|
||||
pattern_match:
|
||||
regex: "(.*)"
|
||||
content: "{{ vrf_item.rd.matches.0 }}"
|
||||
register: rd
|
||||
|
||||
- name: match interfaces
|
||||
pattern_match:
|
||||
regex: "\\s+(\\S+)\\s"
|
||||
content: "{{ vrf_item.interface_section.0.matches }}"
|
||||
match_all: true
|
||||
register: interface
|
||||
|
||||
- name: match export route targets
|
||||
pattern_match:
|
||||
regex: "\\s+RT:(\\d+:\\d+)"
|
||||
content: "{{ vrf_item.export_rt_section.0.matches }}"
|
||||
match_all: true
|
||||
register: export_rt
|
||||
|
||||
- name: match import route targets
|
||||
pattern_match:
|
||||
regex: "\\s+RT:(\\d+:\\d+)"
|
||||
content: "{{ vrf_item.import_rt_section.0.matches }}"
|
||||
match_all: true
|
||||
register: import_rt
|
||||
|
||||
- name: template export json object
|
||||
export: true
|
||||
loop: "{{ vrf_nested_section_values }}"
|
||||
loop_control:
|
||||
loop_var: vrf_nested_item
|
||||
register: vrf
|
||||
extend: cisco_ios
|
||||
export_as: dict
|
||||
json_template:
|
||||
template:
|
||||
- key: "{{ vrf_nested_item.name.matches.0 }}"
|
||||
object:
|
||||
- key: name
|
||||
value: "{{ vrf_nested_item.name.matches.0 }}"
|
||||
- key: description
|
||||
value: "{{ vrf_nested_item.description.matches.0 }}"
|
||||
- key: rd
|
||||
value: "{{ vrf_nested_item.rd.matches.0 }}"
|
||||
- key: export_rt
|
||||
elements: "{{ export_rt_item.matches }}"
|
||||
repeat_for: "{{ vrf_nested_item.export_rt }}"
|
||||
repeat_var: export_rt_item
|
||||
- key: import_rt
|
||||
elements: "{{ import_rt_item.matches }}"
|
||||
repeat_for: "{{ vrf_nested_item.import_rt }}"
|
||||
repeat_var: import_rt_item
|
||||
- key: interface
|
||||
elements: "{{ interface_item.matches }}"
|
||||
repeat_for: "{{ vrf_nested_item.interface }}"
|
||||
repeat_var: interface_item
|
||||
@@ -0,0 +1,52 @@
|
||||
---
|
||||
- name: parser meta data
|
||||
parser_metadata:
|
||||
version: 1.0
|
||||
command: show lldp neighbors detail
|
||||
network_os: ios
|
||||
|
||||
- name: match sections
|
||||
pattern_match:
|
||||
regex: "^-----.*"
|
||||
match_all: true
|
||||
match_greedy: true
|
||||
register: context
|
||||
|
||||
- name: parse lldp neighbors
|
||||
pattern_group:
|
||||
- name: parse local port
|
||||
pattern_match:
|
||||
regex: "Local Intf: (.+)"
|
||||
content: "{{ item }}"
|
||||
register: local_port
|
||||
|
||||
- name: parse remote prort
|
||||
pattern_match:
|
||||
regex: "Port id: (.+)"
|
||||
content: "{{ item }}"
|
||||
register: remote_port
|
||||
|
||||
- name: parse remote host
|
||||
pattern_match:
|
||||
regex: "System Name: (.+)"
|
||||
content: "{{ item }}"
|
||||
register: remote_host
|
||||
|
||||
loop: "{{ context }}"
|
||||
register: matches
|
||||
|
||||
- name: build lldp neighbor facts
|
||||
register: lldp
|
||||
export: true
|
||||
extend: "{{ toplevel | default('cisco_ios') }}"
|
||||
json_template:
|
||||
template:
|
||||
- key: neighbors
|
||||
elements:
|
||||
- key: port
|
||||
value: "{{ item.local_port.matches.0 | expand_interface_name }}"
|
||||
- key: neighbor
|
||||
value: "{{ item.remote_host.matches.0 }}"
|
||||
- key: neighbor_port
|
||||
value: "{{ item.remote_port.matches.0 }}"
|
||||
repeat_for: "{{ matches }}"
|
||||
@@ -0,0 +1,109 @@
|
||||
---
|
||||
- name: parser meta data
|
||||
parser_metadata:
|
||||
version: 1.0
|
||||
command: show version
|
||||
network_os: ios
|
||||
|
||||
- name: match softare version
|
||||
pattern_match:
|
||||
regex: "Cisco IOS Software.*, Version (\\S+),"
|
||||
register: version
|
||||
|
||||
- name: match model
|
||||
pattern_match:
|
||||
regex: "[Cc]isco (.+) \\("
|
||||
register: model
|
||||
|
||||
- name: match hostname
|
||||
pattern_match:
|
||||
regex: "^(\\S+) uptime is"
|
||||
register: hostname
|
||||
|
||||
- name: match image
|
||||
pattern_match:
|
||||
regex: "^System image file is (\\S+)"
|
||||
register: image
|
||||
|
||||
- name: match restart conditions
|
||||
pattern_match:
|
||||
regex: "^System restarted at (?P<time>\\d+:\\d+:\\d+) (?P<tz>\\S+)"
|
||||
register: restart_conditions
|
||||
|
||||
- name: match reload reason
|
||||
pattern_match:
|
||||
regex: "^Last reload reason: (\\S+)"
|
||||
register: reload_reason
|
||||
|
||||
- name: match uptime
|
||||
pattern_match:
|
||||
regex: "uptime is (.+)"
|
||||
register: uptime
|
||||
|
||||
- name: match uptime years
|
||||
pattern_match:
|
||||
regex: "uptime is (\\d+) year"
|
||||
register: uptime_years
|
||||
|
||||
- name: match uptime weeks
|
||||
pattern_match:
|
||||
regex: "(\\d+) week"
|
||||
register: uptime_weeks
|
||||
|
||||
- name: match uptime days
|
||||
pattern_match:
|
||||
regex: "(\\d+) day"
|
||||
register: uptime_days
|
||||
|
||||
- name: match uptime hours
|
||||
pattern_match:
|
||||
regex: "(\\d+) hour"
|
||||
register: uptime_hours
|
||||
|
||||
- name: match uptime minutes
|
||||
pattern_match:
|
||||
regex: "(\\d+) minute"
|
||||
register: uptime_minutes
|
||||
|
||||
- name: match configuration register
|
||||
pattern_match:
|
||||
regex: "register is (.+)"
|
||||
register: confreg
|
||||
|
||||
- name: build ios system state facts
|
||||
json_template:
|
||||
template:
|
||||
- key: version
|
||||
value: "{{ version.matches.0 }}"
|
||||
- key: hostname
|
||||
value: "{{ hostname.matches.0 }}"
|
||||
- key: image_file
|
||||
value: "{{ image.matches.0 }}"
|
||||
- key: model
|
||||
value: "{{ model.matches.0 }}"
|
||||
- key: restart_time
|
||||
value: "{{ restart_conditions.time }}"
|
||||
- key: restart_tz
|
||||
value: "{{ restart_conditions.tz }}"
|
||||
- key: reload_reason
|
||||
value: "{{ reload_reason.matches.0 | lower }}"
|
||||
- key: uptime
|
||||
value: "{{ uptime.matches.0 }}"
|
||||
- key: uptime_split
|
||||
object:
|
||||
- key: years
|
||||
value: "{{ uptime_years.matches.0 | default(0) | int }}"
|
||||
- key: weeks
|
||||
value: "{{ uptime_weeks.matches.0 | default(0) | int }}"
|
||||
- key: days
|
||||
value: "{{ uptime_days.matches.0 | default(0) | int }}"
|
||||
- key: hours
|
||||
value: "{{ uptime_hours.matches.0 | default(0) | int }}"
|
||||
- key: minutes
|
||||
value: "{{ uptime_minutes.matches.0 | default(0) | int }}"
|
||||
- key: configuration_register
|
||||
value: "{{ confreg.matches.0 }}"
|
||||
register: system
|
||||
export: true
|
||||
export_as: dict
|
||||
extend: cisco_ios
|
||||
Reference in New Issue
Block a user