83 lines
2.3 KiB
YAML
Executable File
83 lines
2.3 KiB
YAML
Executable File
---
|
|
- 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: prefix_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: Get current route maps
|
|
cisco.ios.ios_command:
|
|
commands: show run | sec route-map
|
|
register: config_before
|
|
|
|
- name: Print current route maps config
|
|
debug:
|
|
msg: "{{ config_before.stdout_lines }}"
|
|
|
|
- name: Update target route maps
|
|
cisco.ios.ios_route_maps:
|
|
config:
|
|
- route_map: ANSIBLE_MANAGED_ROUTE_MAP
|
|
entries:
|
|
- sequence: "{{ item.SequenceNo }}"
|
|
action: permit
|
|
description: "Attached to {{ item.Site }}"
|
|
match:
|
|
ip:
|
|
next_hop:
|
|
prefix_lists:
|
|
- "{{ item.Site }}"
|
|
state: merged
|
|
loop: "{{ prefix_list.list }}"
|
|
|
|
- name: Get updated route maps
|
|
cisco.ios.ios_command:
|
|
commands: show run | sec route-map
|
|
register: config_after
|
|
|
|
- name: Print updated route maps config
|
|
debug:
|
|
msg: "{{ config_after.stdout_lines }}"
|
|
|