Adding Netbox
This commit is contained in:
@@ -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 }}"
|
||||
Reference in New Issue
Block a user