cisco.iosxr.iosxr_prefix_lists module – Resource module to configure prefix lists.

Note

This module is part of the cisco.iosxr collection (version 9.0.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install cisco.iosxr.

To use it in a playbook, specify: cisco.iosxr.iosxr_prefix_lists.

New in cisco.iosxr 2.3.0

Synopsis

  • This module manages prefix-lists configuration on devices running Cisco IOSXR.

Aliases: prefix_lists

Parameters

Parameter

Comments

config

list / elements=dictionary

A list of prefix-lists configuration.

afi

string

The Address Family Identifier (AFI) for the prefix-lists.

Choices:

  • "ipv4"

  • "ipv6"

prefix_lists

list / elements=dictionary

List of prefix-list configurations.

entries

list / elements=dictionary

List of configurations for the specified prefix-list

action

string

Prefix-List permit or deny.

Choices:

  • "permit"

  • "deny"

  • "remark"

description

string

Description of the prefix list. only applicable for action “remark”.

eq

integer

Exact prefix length to be matched.

ge

integer

Minimum prefix length to be matched.

le

integer

Maximum prefix length to be matched.

prefix

string

IP or IPv6 prefix in A.B.C.D/LEN or A:B::C:D/LEN format. only applicable for action “permit” and “deny”

sequence

integer

Sequence Number.

name

string

Name of the prefix-list.

running_config

string

This option is used only with state parsed.

The value of this option should be the output received from the Iosxr device by executing the command show running-config prefix-list.

The state parsed reads the configuration from running_config option and transforms it into Ansible structured data as per the resource module’s argspec and the value is then returned in the parsed key within the result.

state

string

The state the configuration should be left in.

Refer to examples for more details.

With state replaced, for the listed prefix-lists, sequences that are in running-config but not in the task are negated.

With state overridden, all prefix-lists that are in running-config but not in the task are negated.

Please refer to examples for more details.

Choices:

  • "merged" ← (default)

  • "replaced"

  • "overridden"

  • "deleted"

  • "parsed"

  • "gathered"

  • "rendered"

Notes

Note

  • Tested against IOSXR 7.0.2.

  • This module works with connection network_cli.

Examples

# Using merged


# Before state
# RP/0/0/CPU0:10#show running-config
# Thu Feb  4 09:38:36.245 UTC
# % No such configuration item(s)
# RP/0/0/CPU0:10#
#


- name: Merge the provided configuration with the existing running configuration
  cisco.iosxr.iosxr_prefix_lists:
    state: merged
    config:
      - afi: ipv6
        prefix_lists:
          - name: pl_1
            entries:
              - prefix: '2001:db8:1234::/48'
                action: deny
                sequence: 1
          - name: pl_2
            entries:
              - sequence: 2
                action: remark
                description: TEST_PL_2_REMARK
      - afi: ipv4
        prefix_lists:
          - name: pl1
            entries:
              - sequence: 3
                action: remark
                description: TEST_PL1_2_REMARK
              - sequence: 4
                action: permit
                prefix: 10.0.0.0/24
          - name: pl2
            entries:
              - sequence: 5
                action: remark
                description: TEST_PL2_REMARK
          - name: pl3
            entries:
              - sequence: 6
                action: permit
                prefix: 35.0.0.0/8
                eq: 0

# Task Output
# -------------
# before: []
# commands:
# - ipv6 prefix-list pl_1 1 deny 2001:db8:1234::/48
# - ipv6 prefix-list pl_2 2 remark TEST_PL_2_REMARK
# - ipv4 prefix-list pl1 3 remark TEST_PL1_2_REMARK
# - ipv4 prefix-list pl1 4 permit 10.0.0.0/24
# - ipv4 prefix-list pl2 5 remark TEST_PL2_REMARK
# - ipv4 prefix-list pl3 6 permit 35.0.0.0/8 eq 0
# after:
# - afi: ipv6
#   prefix_lists:
#   - name: pl_1
#     entries:
#     - prefix: 2001:db8:1234::/48
#       action: deny
#       sequence: 1
#   - name: pl_2
#     entries:
#     - sequence: 2
#       action: remark
#       description: TEST_PL_2_REMARK
# - afi: ipv4
#   prefix_lists:
#   - name: pl1
#     entries:
#     - sequence: 3
#       action: remark
#       description: TEST_PL1_2_REMARK
#     - sequence: 4
#       action: permit
#       prefix: 10.0.0.0/24
#   - name: pl2
#     entries:
#     - sequence: 5
#       action: remark
#       description: TEST_PL2_REMARK
#   - name: pl3
#     entries:
#     - sequence: 6
#       action: permit
#       prefix: 35.0.0.0/8
#       eq: 0


# After state:
# ------------
# RP/0/0/CPU0:10#show running-config
# ipv6 prefix-list pl_1
#  1 deny 2001:db8:1234::/48
# !
# ipv6 prefix-list pl_2
#  2 remark TEST_PL_2_REMAR
# !
# ipv4 prefix-list pl1
#  3 remark TEST_PL1_2_REMARK
#  4 permit 10.0.0.0/24
# !
# ipv4 prefix-list pl2
#  5 remark TEST_PL2_REMARK
# !
# ipv4 prefix-list pl3
#  6 permit 35.0.0.0/8 eq 0
# !


# Using replaced:


# Before state:
# -------------
# RP/0/0/CPU0:10#show running-config
#
# ipv6 prefix-list pl_1
#  1 deny 2001:db8:1234::/48
# !
# ipv6 prefix-list pl_2
#  2 remark TEST_PL_2_REMARK
# !
# ipv4 prefix-list pl1
#  3 remark TEST_PL1_2_REMARK
#  4 permit 10.0.0.0/24
# !
# ipv4 prefix-list pl2
#  5 remark TEST_PL2_REMARK
# !
#


- name: >-
    Replace device configurations of listed prefix lists with provided
    configurations
  register: result
  cisco.iosxr.iosxr_prefix_lists:
    config:
      - afi: ipv4
        prefix_lists:
          - name: pl1
            entries:
              - sequence: 3
                action: permit
                prefix: 10.0.0.0/24
      - afi: ipv6
        prefix_lists:
          - name: pl_1
            entries:
              - prefix: '2001:db8:1234::/48'
                action: permit
                sequence: 1
          - name: pl_2
            entries:
              - sequence: 2
                action: remark
                description: TEST_PL1_2
    state: replaced


# Task Output
# -------------
# before:
# - afi: ipv6
#   prefix_lists:
#   - entries:
#     - action: deny
#       prefix: 2001:db8:1234::/48
#       sequence: 1
#     name: pl_1
#   - entries:
#     - action: remark
#       description: TEST_PL_2_REMARK
#       sequence: 2
#     name: pl_2
# - afi: ipv4
#   prefix_lists:
#   - entries:
#     - action: remark
#       description: TEST_PL1_2_REMARK
#       sequence: 3
#     - action: permit
#       prefix: 10.0.0.0/24
#       sequence: 4
#     name: pl1
#   - entries:
#     - action: remark
#       description: TEST_PL2_REMARK
#       sequence: 5
#     name: pl2
# commands:
# - no ipv4 prefix-list pl1 3 remark TEST_PL1_2_REMARK
# - no ipv4 prefix-list pl1 4 permit 10.0.0.0/24
# - ipv4 prefix-list pl1 3 permit 10.0.0.0/24
# - ipv6 prefix-list pl_2 2 remark TEST_PL1_2
# after:
# - afi: ipv6
#   prefix_lists:
#   - entries:
#     - action: deny
#       prefix: 2001:db8:1234::/48
#       sequence: 1
#     name: pl_1
#   - entries:
#     - action: remark
#       description: TEST_PL1_2
#       sequence: 2
#     name: pl_2
# - afi: ipv4
#   prefix_lists:
#   - entries:
#     - action: permit
#       prefix: 10.0.0.0/24
#       sequence: 3
#     name: pl1
#   - entries:
#     - action: remark
#       description: TEST_PL2_REMARK
#       sequence: 5
#     name: pl2


# After state:
# RP/0/0/CPU0:10#show running-config
#
# ipv6 prefix-list pl_1
#  1 deny 2001:db8:1234::/48
# !
# ipv6 prefix-list pl_2
#  2 remark TEST_PL1_2
# !
# ipv4 prefix-list pl1
#  3 permit 10.0.0.0/24
# !
# ipv4 prefix-list pl2
#  5 remark TEST_PL2_REMARK
#
# Module Execution:
#


# Using deleted:


# Before state:
# -------------
# RP/0/0/CPU0:10#show running-config
#
# ipv6 prefix-list pl_1
#  1 deny 2001:db8:1234::/48
# !
# ipv6 prefix-list pl_2
#  2 remark TEST_PL_2_REMARK
# !
# ipv4 prefix-list pl1
#  3 remark TEST_PL1_2_REMARK
#  4 permit 10.0.0.0/24
# !
# ipv4 prefix-list pl2
#  5 remark TEST_PL2_REMARK
# ipv4 prefix-list pl3
#  6 permit 35.0.0.0/8 eq 0

- name: Delete all prefix-lists from the device
  cisco.iosxr.iosxr_prefix_lists:
    state: deleted

# Task Output
# -------------
# before:
# - afi: ipv6
#   prefix_lists:
#   - name: pl_1
#     entries:
#     - prefix: 2001:db8:1234::/48
#       action: deny
#       sequence: 1
#   - name: pl_2
#     entries:
#     - sequence: 2
#       action: remark
#       description: TEST_PL_2_REMARK
# - afi: ipv4
#   prefix_lists:
#   - name: pl1
#     entries:
#     - sequence: 3
#       action: remark
#       description: TEST_PL1_2_REMARK
#     - sequence: 4
#       action: permit
#       prefix: 10.0.0.0/24
#   - name: pl2
#     entries:
#     - sequence: 5
#       action: remark
#       description: TEST_PL2_REMARK
#   - name: pl3
#     entries:
#     - sequence: 6
#       action: permit
#       prefix: 35.0.0.0/8
#       eq: 0
# commands:
# - no ipv6 prefix-list pl_1
# - no ipv6 prefix-list pl_2
# - no ipv4 prefix-list pl1
# - no ipv4 prefix-list pl2
# - no ipv4 prefix-list pl3
# after: []


# After state:
# RP/0/0/CPU0:10#show running-config
#

# using gathered:


# After state:
# ------------
# RP/0/0/CPU0:10#show running-config
# ipv6 prefix-list pl_1
#  1 deny 2001:db8:1234::/48
# !
# ipv6 prefix-list pl_2
#  2 remark TEST_PL_2_REMARK
# !
# ipv4 prefix-list pl1
#  3 remark TEST_PL1_2_REMARK
#  4 permit 10.0.0.0/24
# !
# ipv4 prefix-list pl2
#  5 remark TEST_PL2_REMARK
# !
# ipv4 prefix-list pl3
#  6 permit 35.0.0.0/8 eq 0
# !


- name: Gather ACL interfaces facts using gathered state
  cisco.iosxr.iosxr_prefix_lists:
    state: gathered

# gathered:
# - afi: ipv6
#   prefix_lists:
#   - name: pl_1
#     entries:
#     - prefix: 2001:db8:1234::/48
#       action: deny
#       sequence: 1
#   - name: pl_2
#     entries:
#     - sequence: 2
#       action: remark
#       description: TEST_PL_2_REMARK
# - afi: ipv4
#   prefix_lists:
#   - name: pl1
#     entries:
#     - sequence: 3
#       action: remark
#       description: TEST_PL1_2_REMARK
#     - sequence: 4
#       action: permit
#       prefix: 10.0.0.0/24
#   - name: pl2
#     entries:
#     - sequence: 5
#       action: remark
#       description: TEST_PL2_REMARK
#   - name: pl3
#     entries:
#     - sequence: 6
#       action: permit
#       prefix: 35.0.0.0/8
#       eq: 0


# Using parsed:


# parsed.cfg
# ------------------------------
# ipv6 prefix-list pl_1
#  1 deny 2001:db8:1234::/48
# !
# ipv6 prefix-list pl_2
#  2 remark TEST_PL_2_REMARK
# !
# ipv4 prefix-list pl1
#  3 remark TEST_PL1_2_REMARK
#  4 permit 10.0.0.0/24
# !
# ipv4 prefix-list pl2
#  5 remark TEST_PL2_REMARK


- name: Parse externally provided Prefix_lists config to agnostic model
  cisco.iosxr.iosxr_prefix_lists:
    running_config: '{{ lookup(''file'', ''./fixtures/parsed.cfg'') }}'
    state: parsed


# Task Output
# -------------
# parsed:
# - afi: ipv6
#   prefix_lists:
#   - name: pl_1
#     entries:
#     - prefix: 2001:db8:1234::/48
#       action: deny
#       sequence: 1
#   - name: pl_2
#     entries:
#     - sequence: 2
#       action: remark
#       description: TEST_PL_2_REMARK
# - afi: ipv4
#   prefix_lists:
#   - name: pl1
#     entries:
#     - sequence: 3
#       action: remark
#       description: TEST_PL1_2_REMARK
#     - sequence: 4
#       action: permit
#       prefix: 10.0.0.0/24
#   - name: pl2
#     entries:
#     - sequence: 5
#       action: remark
#       description: TEST_PL2_REMARK
#     - sequence: 6
#       action: permit
#       prefix: 35.0.0.0/8
#       eq: 0


# Using rendered:


- name: Render platform specific commands from task input using rendered state
  register: result
  cisco.iosxr.iosxr_prefix_lists:
    config:
      - afi: ipv6
        prefix_lists:
          - name: pl_1
            entries:
              - prefix: '2001:db8:1234::/48'
                action: deny
                sequence: 1
          - name: pl_2
            entries:
              - sequence: 2
                action: remark
                description: TEST_PL_2_REMARK
      - afi: ipv4
        prefix_lists:
          - name: pl1
            entries:
              - sequence: 3
                action: remark
                description: TEST_PL1_2_REMARK
              - sequence: 4
                action: permit
                prefix: 10.0.0.0/24
          - name: pl2
            entries:
              - sequence: 5
                action: remark
                description: TEST_PL2_REMARK
              - sequence: 6
                action: permit
                prefix: 35.0.0.0/8
                eq: 0
    state: rendered


# Task Output
# -------------
# "rendered": [
#         "ipv6 prefix-list pl_1 1 deny 2001:db8:1234::/48",
#         "ipv6 prefix-list pl_2 2 remark TEST_PL_2_REMARK",
#         "ipv4 prefix-list pl1 3 remark TEST_PL1_2_REMARK",
#         "ipv4 prefix-list pl1 4 permit 10.0.0.0/24",
#         "ipv4 prefix-list pl2 5 remark TEST_PL2_REMARK",
#         "ipv4 prefix-list pl2 6 permit 35.0.0.0/8 eq 0"
#     ]

# Using overridden:


# Before state:
# -------------
# RP/0/0/CPU0:10#show running-config
#
# ipv6 prefix-list pl_1
#  1 deny 2001:db8:1234::/48
# !
# ipv6 prefix-list pl_2
#  2 remark TEST_PL_2_REMARK
# !
# ipv4 prefix-list pl1
#  3 remark TEST_PL1_2_REMARK
#  4 permit 10.0.0.0/24
# !
# ipv4 prefix-list pl2
#  5 remark TEST_PL2_REMARK
#
- name: Overridde all Prefix_lists configuration with provided configuration
  cisco.iosxr.iosxr_prefix_lists:
    config:
      - afi: ipv4
        prefix_lists:
          - name: pl3
            entries:
              - sequence: 3
                action: remark
                description: TEST_PL1_3_REMARK
              - sequence: 4
                action: permit
                prefix: 10.0.0.0/24
              - sequence: 6
                action: permit
                prefix: 35.0.0.0/8
                eq: 0
    state: overridden


# Task Output
# -------------
# before:
# - afi: ipv6
#   prefix_lists:
#   - entries:
#     - action: deny
#       prefix: 2001:db8:1234::/48
#       sequence: 1
#     name: pl_1
#   - entries:
#     - action: remark
#       description: TEST_PL_2_REMARK
#       sequence: 2
#     name: pl_2
# - afi: ipv4
#   prefix_lists:
#   - entries:
#     - action: remark
#       description: TEST_PL1_2_REMARK
#       sequence: 3
#     - action: permit
#       prefix: 10.0.0.0/24
#       sequence: 4
#     name: pl1
#   - entries:
#     - action: remark
#       description: TEST_PL2_REMARK
#       sequence: 5
#     name: pl2
# commands:
# - no ipv6 prefix-list pl_1
# - no ipv6 prefix-list pl_2
# - no ipv4 prefix-list pl1
# - no ipv4 prefix-list pl2
# - ipv4 prefix-list pl3 3 remark TEST_PL1_3_REMARK
# - ipv4 prefix-list pl3 4 permit 10.0.0.0/24
# - ipv4 prefix-list pl3 6 permit 35.0.0.0/8 eq 0
# after:
# - afi: ipv4
#   prefix_lists:
#   - entries:
#     - action: remark
#       description: TEST_PL1_3_REMARK
#       sequence: 3
#     - action: permit
#       prefix: 10.0.0.0/24
#       sequence: 4
#     - action: permit
#       prefix: 35.0.0.0/8
#       sequence: 6
#       eq: 0
#     name: pl3


# After state:
# RP/0/0/CPU0:10#show running-config
#
# ipv4 prefix-list pl3
# 3 remark TEST_PL1_3_REMARK
# 4 permit 10.0.0.0/24
# 6 permit 35.0.0.0/8 eq 0
# !
# !

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

after

dictionary

The resulting configuration after module execution.

Returned: when changed

Sample: "This output will always be in the same format as the module argspec.\n"

before

dictionary

The configuration prior to the module execution.

Returned: when state is merged, replaced, overridden, deleted or purged

Sample: "This output will always be in the same format as the module argspec.\n"

commands

list / elements=string

The set of commands pushed to the remote device.

Returned: when state is merged, replaced, overridden, deleted or purged

Sample: ["ipv6 prefix-list pl_1 1 deny 2001:db8:1234::/48", "ipv6 prefix-list pl_2 2 remark TEST_PL_2_REMARK", "ipv4 prefix-list pl1 3 remark TEST_PL1_2_REMARK", "ipv4 prefix-list pl1 4 permit 10.0.0.0/24", "ipv4 prefix-list pl2 5 remark TEST_PL2_REMARK"]

gathered

list / elements=string

Facts about the network resource gathered from the remote device as structured data.

Returned: when state is gathered

Sample: ["This output will always be in the same format as the module argspec.\n"]

parsed

list / elements=string

The device native config provided in running_config option parsed into structured data as per module argspec.

Returned: when state is parsed

Sample: ["This output will always be in the same format as the module argspec.\n"]

rendered

list / elements=string

The provided configuration in the task rendered in device-native format (offline).

Returned: when state is rendered

Sample: ["ipv6 prefix-list pl_1 1 deny 2001:db8:1234::/48", "ipv6 prefix-list pl_2 2 remark TEST_PL_2_REMARK", "ipv4 prefix-list pl1 3 remark TEST_PL1_2_REMARK", "ipv4 prefix-list pl1 4 permit 10.0.0.0/24", "ipv4 prefix-list pl2 5 remark TEST_PL2_REMARK"]

Authors

  • Ashwini Mhatre (@amhatre)