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
|
||||
@@ -0,0 +1,87 @@
|
||||
---
|
||||
- name: match sections
|
||||
pattern_match:
|
||||
regex: "^ip"
|
||||
match_all: true
|
||||
match_greedy: true
|
||||
register: context
|
||||
|
||||
- name: match prefix values
|
||||
pattern_group:
|
||||
- name: match name
|
||||
pattern_match:
|
||||
regex: "ip prefix-list (?P<acl_name>.+): (\\d+) entries"
|
||||
content: "{{ item }}"
|
||||
register: name
|
||||
|
||||
- name: match entries
|
||||
pattern_match:
|
||||
regex: "seq (\\d+) (permit|deny) (\\S+)(?: (le|ge) (\\d+))*"
|
||||
content: "{{ item }}"
|
||||
match_all: true
|
||||
register: entry
|
||||
loop: "{{ context }}"
|
||||
register: entries
|
||||
|
||||
- name: template entries
|
||||
json_template:
|
||||
template:
|
||||
- key: name
|
||||
value: "{{ item.name.acl_name }}"
|
||||
- key: entries
|
||||
elements:
|
||||
- key: sequence
|
||||
value: "{{ it.matches.0 }}"
|
||||
- key: action
|
||||
value: "{{ it.matches.1 }}"
|
||||
- key: prefix
|
||||
value: "{{ it.matches.2 }}"
|
||||
- key: operator
|
||||
value: "{{ it.matches.4 }}"
|
||||
- key: length
|
||||
value: "{{ it.matches.5 }}"
|
||||
repeat_for: "{{ item.entry }}"
|
||||
repeat_var: it
|
||||
register: prefix_list_list
|
||||
export: true
|
||||
loop: "{{ entries }}"
|
||||
|
||||
- name: template entries
|
||||
json_template:
|
||||
template:
|
||||
- key: "{{ item.name.acl_name }}"
|
||||
object:
|
||||
- key: entries
|
||||
elements:
|
||||
- key: sequence
|
||||
value: "{{ it.matches.0 }}"
|
||||
- key: action
|
||||
value: "{{ it.matches.1 }}"
|
||||
- key: prefix
|
||||
value: "{{ it.matches.2 }}"
|
||||
- key: operator
|
||||
value: "{{ it.matches.3 }}"
|
||||
- key: length
|
||||
value: "{{ it.matches.4 }}"
|
||||
repeat_for: "{{ item.entry }}"
|
||||
repeat_var: it
|
||||
loop: "{{ entries }}"
|
||||
export: true
|
||||
export_as: dict
|
||||
extend: cisco_ios.config
|
||||
register: prefix_list_dict
|
||||
|
||||
- name: template acl and prefix
|
||||
json_template:
|
||||
template:
|
||||
- key: acl
|
||||
elements:
|
||||
- key: acl_name
|
||||
value: "{{ item.name.acl_name }}"
|
||||
- key: prefix
|
||||
value: "{{ it.matches.2 }}"
|
||||
repeat_for: "{{ item.entry }}"
|
||||
repeat_var: it
|
||||
register: prefix_list_basic
|
||||
export: true
|
||||
loop: "{{ entries }}"
|
||||
@@ -0,0 +1,90 @@
|
||||
---
|
||||
- name: match sections
|
||||
pattern_match:
|
||||
regex: "interface"
|
||||
match_all: true
|
||||
match_greedy: true
|
||||
register: section
|
||||
|
||||
- name: match interface config values
|
||||
pattern_group:
|
||||
- name: match name
|
||||
pattern_match:
|
||||
regex: "interface (.*)"
|
||||
content: "{{ item }}"
|
||||
register: name
|
||||
|
||||
- name: match description
|
||||
pattern_match:
|
||||
regex: "description (.*)"
|
||||
content: "{{ item }}"
|
||||
register: description
|
||||
|
||||
- name: match admin state
|
||||
pattern_match:
|
||||
regex: "(shutdown)"
|
||||
content: "{{ item }}"
|
||||
register: enabled
|
||||
|
||||
- name: match ip_helper
|
||||
pattern_match:
|
||||
regex: "ip helper-address (.*)"
|
||||
match_all: true
|
||||
content: "{{ item }}"
|
||||
register: ip_helper
|
||||
|
||||
- name: match cdp enable
|
||||
pattern_match:
|
||||
regex: "(no) cdp enable"
|
||||
content: "{{ item }}"
|
||||
register: cdp_enable
|
||||
|
||||
- name: match speed
|
||||
pattern_match:
|
||||
regex: 'speed (.+)'
|
||||
content: "{{ item }}"
|
||||
register: speed
|
||||
|
||||
- name: match duplex
|
||||
pattern_match:
|
||||
regex: 'duplex (.+)'
|
||||
content: "{{ item }}"
|
||||
register: duplex
|
||||
|
||||
- name: match ip_address
|
||||
pattern_match:
|
||||
regex: "ip address (.*)"
|
||||
match_all: true
|
||||
content: "{{ item }}"
|
||||
register: ip_address
|
||||
loop: "{{ section }}"
|
||||
register: values
|
||||
|
||||
- name: template interface values
|
||||
loop: "{{ values }}"
|
||||
register: interface-config
|
||||
export: true
|
||||
export_as: dict
|
||||
extend: cisco_ios.config
|
||||
json_template:
|
||||
template:
|
||||
- key: "{{ item.name.matches.0 }}"
|
||||
object:
|
||||
- key: name
|
||||
value: "{{ item.name.matches.0 }}"
|
||||
- key: ip_addess
|
||||
value: "{{ item.ip_address | map(attribute='matches') | list }}"
|
||||
- key: description
|
||||
value: "{{ item.description.matches.0 }}"
|
||||
- key: ip_helper
|
||||
value: "{{ item.ip_helper | map(attribute='matches') | list }}"
|
||||
- key: enabled
|
||||
value: "{{ not item.enabled.matches }}"
|
||||
- key: mtu
|
||||
value: "{{ item.mtu.matches.0 }}"
|
||||
- key: speed
|
||||
value: "{{ item.speed.matches.0 }}"
|
||||
- key: duplex
|
||||
value: "{{ item.duplex.matches.0 }}"
|
||||
- key: cdp
|
||||
value: "{{ not item.cdp_enable.matches }}"
|
||||
@@ -0,0 +1,23 @@
|
||||
---
|
||||
- name: parse hostname
|
||||
pattern_match:
|
||||
regex: "hostname (.+)"
|
||||
register: hostname
|
||||
|
||||
- name: parse domain-name
|
||||
pattern_match:
|
||||
regex: "ip domain-name (.+)"
|
||||
register: domain_name
|
||||
|
||||
- name: parse ip routing
|
||||
pattern_match:
|
||||
regex: "(ip routing)"
|
||||
register: routing
|
||||
|
||||
- name: set global config facts
|
||||
set_vars:
|
||||
hostname: "{{ hostname.matches.0 }}"
|
||||
domain_name: "{{ domain_name.matches.0 }}"
|
||||
routing: "{{ routing.matches.0 is defined }}"
|
||||
export: true
|
||||
extend: cisco_ios.config
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
Value Required,Filldown ACL_TYPE (Standard|Extended)
|
||||
Value Required,Filldown ACL_NAME (\S+)
|
||||
Value LINE_NUM (\d+)
|
||||
Value ACTION (permit|deny)
|
||||
Value PROTOCOL ([a-z]+)
|
||||
Value SRC_HOST (\d+\.\d+\.\d+\.\d+)
|
||||
Value SRC_ANY (any)
|
||||
Value SRC_NETWORK (\d+\.\d+\.\d+\.\d+)
|
||||
Value SRC_WILDCARD (\d+\.\d+\.\d+\.\d+)
|
||||
Value SRC_PORT_MATCH (eq|neq|range|lt|gt)
|
||||
Value SRC_PORT ((?<!range\s).+?)
|
||||
Value SRC_PORT_RANGE_START ((?<=range\s)\S+)
|
||||
Value SRC_PORT_RANGE_END (\S+)
|
||||
Value DST_HOST (\d+\.\d+\.\d+\.\d+)
|
||||
Value DST_ANY (any)
|
||||
Value DST_NETWORK (\d+\.\d+\.\d+\.\d+)
|
||||
Value DST_WILDCARD (\d+\.\d+\.\d+\.\d+)
|
||||
Value DST_PORT_MATCH (eq|neq|range|lt|gt)
|
||||
Value DST_PORT ((?<!range\s).+?)
|
||||
Value DST_PORT_RANGE_START ((?<=range\s)\S+)
|
||||
Value DST_PORT_RANGE_END (\S+)
|
||||
Value FLAGS_MATCH (match-all|match-any)
|
||||
Value TCP_FLAG (((\+|-|)ack(\s*?)|(\+|-|)established(\s*?)|(\+|-|)fin(\s*?)|(\+|-|)fragments(\s*?)|(\+|-|)psh(\s*?)|(\+|-|)rst(\s*?)|(\+|-|)syn(\s*?)|urg(\s*?))+)
|
||||
Value LOG (log-input|log)
|
||||
Value TIME (\S+)
|
||||
Value STATE (inactive|active)
|
||||
Value MATCHES (\d+)
|
||||
Value MATCH (\d+)
|
||||
|
||||
Start
|
||||
^(Standard|Extended) -> Continue.Clearall
|
||||
^${ACL_TYPE}\s+IP\s+access\s+list\s+${ACL_NAME}\s* -> Record
|
||||
^\s+${LINE_NUM}\s+${ACTION}\s+${PROTOCOL}\s+(host\s+${SRC_HOST}|${SRC_ANY}|${SRC_NETWORK}\s+${SRC_WILDCARD})(\s+${SRC_PORT_MATCH}\s+|)(${SRC_PORT_RANGE_START}\s+${SRC_PORT_RANGE_END}|${SRC_PORT}|)\s+(host\s+${DST_HOST}|${DST_ANY}|${DST_NETWORK}\s+${DST_WILDCARD})(\s+${DST_PORT_MATCH}\s+(${DST_PORT_RANGE_START}\s+${DST_PORT_RANGE_END}|${DST_PORT}|)|\s+(${FLAGS_MATCH}\s+|)${TCP_FLAG}|)(\s+${LOG}|)(\s+time-range\s+${TIME}\s+\(${STATE}\)|)(?:\s+\(${MATCHES}\s+matches\)|)(?:\s+\(${MATCH}\s+match\)|)\s*$$ -> Record
|
||||
^\s+${LINE_NUM}\s+${ACTION}\s+(${SRC_NETWORK},\s+wildcard\s+bits\s+${SRC_WILDCARD}|${SRC_HOST}|${SRC_ANY})(\s+${LOG}|)(\s+time-range\s+${TIME}\s+\(${STATE}\)|)(?:\s+\(${MATCHES}\s+matches\)|)\s*$$ -> Record
|
||||
^.* -> Error "Could not parse line:"
|
||||
|
||||
EOF
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
Value src (\d+.\d+.\d+.\d+)
|
||||
Value dst (\d+.\d+.\d+.\d+)
|
||||
Value proto (\S+)
|
||||
Value src_port (\d+)
|
||||
Value dst_port (\d+)
|
||||
Value num_packets (\d+)
|
||||
|
||||
Start
|
||||
^.*permitted ${proto} ${src}\(${src_port}\)(?:\s|-|>)*${dst}\(${dst_port}\), ${num_packets} packet.* -> Record
|
||||
Reference in New Issue
Block a user