dellemc.enterprise_sonic.sonic_prefix_lists module – prefix list configuration handling for SONiC

Note

This module is part of the dellemc.enterprise_sonic collection (version 2.5.1).

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 dellemc.enterprise_sonic.

To use it in a playbook, specify: dellemc.enterprise_sonic.sonic_prefix_lists.

New in dellemc.enterprise_sonic 2.0.0

Synopsis

  • This module provides configuration management for prefix list parameters on devices running SONiC.

Parameters

Parameter

Comments

config

list / elements=dictionary

Specifies a list of prefix set configuration dictionaries

afi

string

Specifies the Address Family for addresses in the prefix list entries

Choices:

  • "ipv4" ← (default)

  • "ipv6"

name

string / required

Name of a prefix set (a list of prefix entries)

prefixes

list / elements=dictionary

A list of prefix entries

action

string / required

Action to be taken for addresses matching this prefix entry

Choices:

  • "permit"

  • "deny"

ge

integer

Minimum prefix length to be matched

le

integer

Maximum prefix length to be matched

prefix

string / required

IPv4 or IPv6 prefix in A.B.C.D/LEN or A:B::C:D/LEN format

sequence

integer / required

Precedence for this prefix entry (unique within the prefix list)

state

string

Specifies the type of configuration update to be performed on the device.

For “merged”, merge specified attributes with existing configured attributes.

For “deleted”, delete the specified attributes from existing configuration.

For “replaced”, replace the specified existing configuration with the provided configuration.

For “overridden”, override the existing configuration with the provided configuration.

Choices:

  • "merged" ← (default)

  • "deleted"

  • "replaced"

  • "overridden"

Notes

Note

  • Supports check_mode.

  • Supports D(diff_mode).

Examples

# Using "merged" state to create initial configuration
#
# Before state:
# -------------
#
# sonic# show running-configuration ip prefix-list
# sonic#
# (No configuration present)
#
# -------------
#
- name: Merge initial prefix-list configuration
  dellemc.enterprise_sonic.sonic_prefix_lists:
     config:
       - name: pfx1
         afi: "ipv4"
         prefixes:
           - sequence: 10
             prefix: "1.2.3.4/24"
             action: "permit"
             ge: 26
             le: 30
     state: merged

# After state:
# ------------
#
# sonic# show running-configuration ip prefix-list
# !
# ip prefix-list pfx1 seq 10 permit 1.2.3.4/24 ge 26 le 30
# ------------
#
# ***************************************************************
# Using "merged" state to update and add configuration
#
# Before state:
# ------------
#
# sonic# show running-configuration ip prefix-list
# !
# ip prefix-list pfx1 seq 10 permit 1.2.3.4/24 ge 26 le 30
#
# sonic# show running-configuration ipv6 prefix-list
# sonic#
# (no IPv6 prefix-list configuration present)
#
# ------------
#
- name: Merge additional prefix-list configuration
  dellemc.enterprise_sonic.sonic_prefix_lists:
     config:
       - name: pfx1
         afi: "ipv4"
         prefixes:
           - sequence: 20
             action: "deny"
             prefix: "1.2.3.12/26"
           - sequence: 30
             action: "permit"
             prefix: "7.8.9.0/24"
       - name: pfx6
         afi: "ipv6"
         prefixes:
           - sequence: 25
             action: "permit"
             prefix: "40::300/124"
     state: merged

# After state:
# ------------
#
# sonic# show running-configuration ip prefix-list
# !
# ip prefix-list pfx1 seq 10 permit 1.2.3.4/24 ge 26 le 30
# ip prefix-list pfx1 seq 20 deny 1.2.3.12/26
# ip prefix-list pfx1 seq 30 permit 7.8.9.0/24
#
# sonic# show running-configuration ipv6 prefix-list
# !
# ipv6 prefix-list pfx6 seq 25 permit 40::300/124
#
# ***************************************************************
# Using "deleted" state to remove configuration
#
# Before state:
# ------------
#
# sonic# show running-configuration ip prefix-list
# !
# ip prefix-list pfx1 seq 10 permit 1.2.3.4/24 ge 26 le 30
# ip prefix-list pfx1 seq 20 deny 1.2.3.12/26
# ip prefix-list pfx1 seq 30 permit 7.8.9.0/24
#
# sonic# show running-configuration ipv6 prefix-list
# !
# ipv6 prefix-list pfx6 seq 25 permit 40::300/124
#
# ------------
#
- name: Delete selected prefix-list configuration
  dellemc.enterprise_sonic.sonic_prefix_lists:
     config:
       - name: pfx1
         afi: "ipv4"
         prefixes:
           - sequence: 10
             prefix: "1.2.3.4/24"
             action: "permit"
             ge: 26
             le: 30
           - sequence: 20
             action: "deny"
             prefix: "1.2.3.12/26"
       - name: pfx6
         afi: "ipv6"
         prefixes:
           - sequence: 25
             action: "permit"
             prefix: "40::300/124"
     state: deleted

# After state:
# ------------
#
# sonic# show running-configuration ip prefix-list
# !
# ip prefix-list pfx1 seq 30 permit 7.8.9.0/24
#
# sonic# show running-configuration ipv6 prefix-list
# sonic#
# (no IPv6 prefix-list configuration present)
#
# ***************************************************************
# Using "overriden" state to override configuration
#
# Before state:
# ------------
#
# sonic# show running-configuration ip prefix-list
# !
# ip prefix-list pfx1 seq 10 permit 1.2.3.4/24 ge 26 le 30
# ip prefix-list pfx3 seq 20 deny 1.2.3.12/26
# ip prefix-list pfx4 seq 30 permit 7.8.9.0/24
#
# sonic# show running-configuration ipv6 prefix-list
# !
# ipv6 prefix-list pfx6 seq 25 permit 40::300/124
#
# ------------
#
- name: Override prefix-list configuration
  dellemc.enterprise_sonic.sonic_prefix_lists:
     config:
       - name: pfx2
         afi: "ipv4"
         prefixes:
           - sequence: 10
             prefix: "10.20.30.128/24"
             action: "deny"
             ge: 25
             le: 30
     state: overridden

# After state:
# ------------
#
# sonic# show running-configuration ip prefix-list
# !
# ip prefix-list pfx2 seq 10 deny 10.20.30.128/24 ge 25 le 30
#
# sonic# show running-configuration ipv6 prefix-list
# sonic#
# (no IPv6 prefix-list configuration present)
#
# ***************************************************************
# Using "replaced" state to replace configuration
#
# Before state:
# ------------
#
# sonic# show running-configuration ip prefix-list
# !
# ip prefix-list pfx2 seq 10 deny 10.20.30.128/24 ge 25 le 30
#
# sonic# show running-configuration ipv6 prefix-list
# sonic#
# (no IPv6 prefix-list configuration present)
#
# ------------
#
- name: Replace prefix-list configuration
  dellemc.enterprise_sonic.sonic_prefix_lists:
     config:
       - name: pfx2
         afi: "ipv4"
         prefixes:
           - sequence: 10
             prefix: "10.20.30.128/24"
             action: "permit"
             ge: 25
             le: 30
       - name: pfx3
         afi: "ipv6"
         prefixes:
           - sequence: 20
             action: "deny"
             prefix: "60::70/124"
     state: replaced

# After state:
# ------------
#
# sonic# show running-configuration ip prefix-list
# !
# ip prefix-list pfx2 seq 10 permit 10.20.30.128/24 ge 25 le 30
#
# sonic# show running-configuration ipv6 prefix-list
# sonic#
# !
# ipv6 prefix-list pfx3 seq 20 deny 60::70/124
#

Return Values

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

Key

Description

after

list / elements=string

The resulting configuration module invocation.

Returned: when changed

Sample: ["The configuration returned will always be in the same format as the parameters above.\n"]

after(generated)

list / elements=string

The generated configuration module invocation.

Returned: when check_mode

Sample: ["The configuration returned will always be in the same format as the parameters above.\n"]

before

list / elements=string

The configuration prior to the module invocation.

Returned: always

Sample: ["The configuration returned will always be in the same format as the parameters above.\n"]

commands

list / elements=string

The set of commands pushed to the remote device.

Returned: always

Sample: ["command 1", "command 2", "command 3"]

diff

list / elements=string

The difference between ‘before’ and ‘after’ (or ‘after(generated)’).

Returned: when D(diff_mode)

Sample: ["The difference shows several lines of context around the lines that differ.\n"]

Authors

  • Kerry Meyer (@kerry-meyer)