Can now use native route_maps module from Ansible IOS collection. Had to upgrade Ansible to 2.10 and the collection to 4.2
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
---
|
||||
- name: Update device prefix list
|
||||
hosts: targets
|
||||
gather_facts: false
|
||||
connection: network_cli
|
||||
roles:
|
||||
- common
|
||||
tasks:
|
||||
|
||||
# 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: 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:
|
||||
msg: "{{ config_before.stdout_lines }}"
|
||||
|
||||
- name: Apply new prefix lists
|
||||
cisco.ios.ios_prefix_lists:
|
||||
config:
|
||||
- afi: ipv4
|
||||
prefix_lists:
|
||||
- name: "{{ item.Site }}"
|
||||
description: "{{ item.Description }}"
|
||||
entries:
|
||||
- action: permit
|
||||
prefix: "{{ item.Prefix }}"
|
||||
sequence: 10
|
||||
state: merged
|
||||
loop: "{{ prefix_list.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:
|
||||
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 }}"
|
||||
Reference in New Issue
Block a user