dellemc.enterprise_sonic.sonic_network_policy module – Manage network policy configuration on SONiC

Note

This module is part of the dellemc.enterprise_sonic collection (version 3.2.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 dellemc.enterprise_sonic.

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

New in dellemc.enterprise_sonic 3.1.0

Synopsis

  • This module provides configuration management of network policy for devices running SONiC

Parameters

Parameter

Comments

config

list / elements=dictionary

List of network policy configurations

applications

list / elements=dictionary

List of network policy application configurations

dot1p and vlan_id are mutually exclusive

dot1p cannot be configured when untagged=True

app_type

string / required

Media type of the application

Choices:

  • "voice"

  • "voice-signaling"

dot1p

string

Enable dot1p priority tagging

Choices:

  • "enabled"

dscp

integer

DSCP value of VLAN, range 0-63

priority

integer

Priority of VLAN, range 0-7

untagged

boolean

Indicates that the application is using an untagged VLAN

Choices:

  • false

  • true

vlan_id

integer

VLAN identifier, range 1-4094

number

integer / required

Network policy number, range 1-128

state

string

The state of the configuration after module completion

Choices:

  • "merged" ← (default)

  • "deleted"

  • "replaced"

  • "overridden"

Notes

Note

  • Tested against Enterprise SONiC Distribution by Dell Technologies.

  • Supports check_mode.

Examples

# Using "merged" state
#
# Before state:
# -------------
#
# sonic# show running-configuration
# (No network policy configuration present)

- name: Merge network policy configuration
  dellemc.enterprise_sonic.sonic_network_policy:
    config:
      - number: 1
        applications:
          - app_type: voice
            vlan_id: 2
            priority: 1
            dscp: 1
          - app_type: voice-signaling
            dot1p: enabled
            dscp: 50
    state: merged

# After state:
# ------------
#
# sonic# show running-configuration
# !
# network-policy profile 1
#  voice vlan 2 cos 1 dscp 1
#  voice-signaling vlan dot1p dscp 50
# !


# Using "replaced" state
#
# Before state:
# -------------
#
# sonic# show running-configuration
# !
# network-policy profile 1
#  voice vlan 2 cos 1 dscp 1
#  voice-signaling vlan 3 untagged dscp 50
# !
# network-policy profile 2
#  voice vlan 100 cos 7 dscp 12
#  voice-signaling vlan 400 cos 7 dscp 45
# !

- name: Replace network policy configuration
  dellemc.enterprise_sonic.sonic_network_policy:
    config:
      - number: 1
        applications:
          - app_type: voice
            vlan_id: 1
            untagged: false
            priority: 0
            dscp: 0
    state: replaced

# After state:
# ------------
#
# sonic# show running-configuration
# !
# network-policy profile 1
#  voice vlan 1 cos 0 dscp 0
# !
# network-policy profile 2
#  voice vlan 100 cos 7 dscp 12
#  voice-signaling vlan 400 cos 7 dscp 45
# !


# Using "overridden" state
#
# Before state:
# -------------
#
# sonic# show running-configuration
# !
# network-policy profile 1
#  voice vlan 2 cos 1 dscp 1
#  voice-signaling vlan 3 untagged dscp 50
# !
# network-policy profile 2
#  voice vlan 100 cos 7 dscp 12
#  voice-signaling vlan 400 cos 7 dscp 45
# !

- name: Override network policy configuration
  dellemc.enterprise_sonic.sonic_network_policy:
    config:
      - number: 1
        applications:
          - app_type: voice
            vlan_id: 1
            untagged: false
            priority: 0
            dscp: 0
    state: overridden

# After state:
# ------------
#
# sonic# show running-configuration
# !
# network-policy profile 1
#  voice vlan 1 cos 0 dscp 0
# !


# Using "deleted" state
#
# Before state:
# -------------
#
# sonic# show running-configuration
# !
# network-policy profile 1
#  voice vlan 2 cos 1 dscp 1
#  voice-signaling vlan 3 untagged dscp 50
# !
# network-policy profile 2
#  voice vlan 100 cos 7 dscp 12
#  voice-signaling vlan 400 cos 7 dscp 45
# !
# network-policy profile 3
#  voice-signaling vlan 80 cos 6 dscp 32
# !

- name: Delete network policy configuration
  dellemc.enterprise_sonic.sonic_network_policy:
    config:
      - number: 1
        applications:
          - app_type: voice
            dscp: 1
      - number: 2
        applications:
          - app_type: voice
      - number: 3
    state: deleted

# After state:
# ------------
#
# sonic# show running-configuration
# !
# network-policy profile 1
#  voice vlan 2 cos 1
#  voice-signaling vlan 3 untagged dscp 50
# !
# network-policy profile 2
#  voice-signaling vlan 400 cos 7 dscp 45
# !


# Using "deleted" state
#
# Before state:
# -------------
#
# sonic# show running-configuration
# !
# network-policy profile 1
#  voice vlan 2 cos 1 dscp 1
#  voice-signaling vlan 3 untagged dscp 50
# !
# network-policy profile 2
#  voice vlan 100 cos 7 dscp 12
#  voice-signaling vlan 400 cos 7 dscp 45
# !
# network-policy profile 3
#  voice-signaling vlan 80 cos 6 dscp 32
# !

- name: Delete all network policy configuration
  dellemc.enterprise_sonic.sonic_network_policy:
    config:
    state: deleted

# After state:
# ------------
#
# sonic# show running-configuration
# (No network policy configuration present)

Return Values

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

Key

Description

after

list / elements=string

The configuration resulting from module invocation.

Returned: when changed

after(generated)

list / elements=string

The generated configuration from module invocation.

Returned: when check_mode

before

list / elements=string

The configuration prior to the module invocation.

Returned: always

commands

list / elements=string

The set of commands pushed to the remote device.

Returned: always

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

Authors

    1. Talabi (@stalabi1)