POC prefix list loader tool. Reads from CSV and loads into IOSXE + assigns to route-map
This commit is contained in:
parent
a1a0a6309c
commit
c0037f946c
7
ios_devices/prefix_list.csv
Normal file
7
ios_devices/prefix_list.csv
Normal file
@ -0,0 +1,7 @@
|
||||
Site,Description,SequenceNo,Prefix
|
||||
site1,desc1,10,1.1.1.1/32
|
||||
site2,desc2,20,2.2.2.2/32
|
||||
site3,desc3,30,3.3.3.3/32
|
||||
site5,Some text here,40,5.5.5.5/32
|
||||
new_site1,aaaaaa,50,6.6.6.6/32
|
||||
oooo_site,zzzzzz,60,7.7.7.7/32
|
||||
|
@ -1,12 +0,0 @@
|
||||
---
|
||||
prefixes:
|
||||
- prefix: 1.1.1.1/32
|
||||
sequence: 5
|
||||
site_name: site_1
|
||||
site_desc: some_desc
|
||||
- prefix: 1.1.1.2/32
|
||||
sequence: 10
|
||||
- prefix: 1.1.1.4/32
|
||||
sequence: 15
|
||||
- prefix: 1.2.3.4/32
|
||||
sequence: 20
|
||||
@ -5,37 +5,50 @@
|
||||
connection: network_cli
|
||||
roles:
|
||||
- common
|
||||
vars_files:
|
||||
- ./prefix_list.yml
|
||||
tasks:
|
||||
|
||||
- name: Collect current prefix list
|
||||
cisco.ios.ios_prefix_lists:
|
||||
config:
|
||||
state: gathered
|
||||
register: result
|
||||
# Read the CSV file and return a list of dicts with column names as keys
|
||||
- name: Read CSV file with prefixes information
|
||||
read_csv:
|
||||
path: prefixes_list.csv
|
||||
register: prefix_list
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Print current prefix list information
|
||||
- name: Get current prefix lists config
|
||||
cisco.ios.ios_command:
|
||||
commands: show run | i ip prefix-list
|
||||
register: config_before
|
||||
|
||||
- name: Print current prefix lists config
|
||||
debug:
|
||||
var: result.gathered
|
||||
msg: "{{ config_before.stdout_lines }}"
|
||||
|
||||
- name: Validate new prefix list
|
||||
- name: Apply new prefix lists
|
||||
cisco.ios.ios_prefix_lists:
|
||||
config:
|
||||
- afi: ipv4
|
||||
prefix_lists:
|
||||
- name: MIGRATED_SITE_SUBNETS-DUBLIN
|
||||
description: SOME_DESCRIPTION-DUBLIN
|
||||
- name: "{{ item.Site }}"
|
||||
description: "{{ item.Description }}"
|
||||
entries:
|
||||
- action: permit
|
||||
prefix: "{{ item.prefix }}"
|
||||
sequence: "{{ item.sequence | int }}"
|
||||
prefix: "{{ item.Prefix }}"
|
||||
sequence: 10
|
||||
state: merged
|
||||
loop: "{{ prefixes }}"
|
||||
register: new_prefix_list
|
||||
loop: "{{ prefix_list.list }}"
|
||||
|
||||
- name: Display new prefix list
|
||||
- name: Get updated prefix lists config
|
||||
cisco.ios.ios_command:
|
||||
commands: show run | i ip prefix-list
|
||||
register: config_after
|
||||
|
||||
- name: Print updated prefix lists config
|
||||
debug:
|
||||
var: "{{item.rendered}}"
|
||||
loop: "{{ new_prefix_list.results }}"
|
||||
msg: "{{ config_after.stdout_lines }}"
|
||||
|
||||
- name: Update target route map
|
||||
cisco.ios.ios_config:
|
||||
lines:
|
||||
- "route-map TEST_MAP permit {{ item.SequenceNo }}"
|
||||
- " match ip next-hop prefix-list {{ item.Site }}"
|
||||
loop: "{{ prefix_list.list }}"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user