ansible_cache/ios_devices/prefix_list_update.yml

55 lines
1.5 KiB
YAML
Raw Normal View History

---
- name: Update device prefix list
hosts: testhosts
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 }}"