dellemc.enterprise_sonic.sonic_vlans module – Manage VLAN and its parameters

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_vlans.

New in dellemc.enterprise_sonic 1.0.0

Synopsis

  • This module provides configuration management of VLANs parameters on devices running Enterprise SONiC Distribution by Dell Technologies.

Parameters

Parameter

Comments

config

list / elements=dictionary

A dictionary of VLAN options.

autostate

boolean

added in dellemc.enterprise_sonic 3.1.0

Enable or disable autostate functionality for the VLAN interface.

Default value for this field if not configured yet will be “enable” which is equivalent to true.

Choices:

  • false

  • true

description

string

Description about the VLAN.

vlan_id

integer / required

ID of the VLAN

Range is 1 to 4094

state

string

The state that the configuration should be left in.

Choices:

  • "merged" ← (default)

  • "replaced"

  • "overridden"

  • "deleted"

Notes

Note

  • Tested against Enterprise SONiC Distribution by Dell Technologies.

  • Supports check_mode.

Examples

# Using "merged" state

# Before state:
# -------------
#
# sonic# show Vlan
# Q: A - Access (Untagged), T - Tagged
# NUM        Status      Q Ports
# 10         Inactive
# 30         Inactive
#
# sonic#
#


- name: Merges given VLAN attributes with the device configuration
  dellemc.enterprise_sonic.sonic_vlans:
    config:
      - vlan_id: 10
        description: "Internal"
    state: merged

# After state:
# ------------
#
# sonic# show Vlan
# Q: A - Access (Untagged), T - Tagged
# NUM        Status      Q Ports
# 10         Inactive
# 30         Inactive
#
# sonic#
#
# sonic# show interface Vlan 10
# Description: Internal
# Vlan10 is up
# Mode of IPV4 address assignment: not-set
# Mode of IPV6 address assignment: not-set
# IP MTU 6000 bytes
# sonic#
#

# Using "replaced" state

# Before state:
# -------------
#
# sonic# show Vlan
# Q: A - Access (Untagged), T - Tagged
# NUM        Status      Q Ports
# 10         Inactive
# 30         Inactive
#
# sonic#

- name: Replace all attributes of specified VLANs with provided configuration
  dellemc.enterprise_sonic.sonic_vlans:
    config:
      - vlan_id: 10
    state: replaced

# After state:
# ------------
#
# sonic# show Vlan
# Q: A - Access (Untagged), T - Tagged
# NUM        Status      Q Ports
# 10         Inactive
# 30         Inactive
#
# sonic#

# Using "overridden" state

# Before state:
# -------------
#
# sonic# show Vlan
# Q: A - Access (Untagged), T - Tagged
# NUM        Status      Q Ports
# 10         Inactive
# 30         Inactive
#
# sonic#

- name: Override device configuration of all VLANs with provided configuration
  dellemc.enterprise_sonic.sonic_vlans:
    config:
      - vlan_id: 10
    state: overridden

# After state:
# ------------
#
# sonic# show Vlan
# Q: A - Access (Untagged), T - Tagged
# NUM        Status      Q Ports
# 10         Inactive
#
# sonic#

# Using "deleted" state

# Before state:
# -------------
#
# sonic# show interface Vlan 70
# Description: Internal
# Vlan70 is up
# Mode of IPV4 address assignment: not-set
# Mode of IPV6 address assignment: not-set
# IP MTU 6000 bytes

- name: Deletes attributes of the given VLANs
  dellemc.enterprise_sonic.sonic_vlans:
    config:
      - vlan_id: 70
        description: "Internal"
    state: deleted

# After state:
# ------------
#
# sonic# show interface Vlan 70
# Vlan70 is up
# Mode of IPV4 address assignment: not-set
# Mode of IPV6 address assignment: not-set
# IP MTU 6000 bytes

# Before state:
# -------------
#
# sonic# show Vlan
# Q: A - Access (Untagged), T - Tagged
# NUM        Status      Q Ports
# 10         Inactive
# 20         Inactive
#
# sonic#

- name: Deletes attributes of the given VLANs
  dellemc.enterprise_sonic.sonic_vlans:
    config:
      - vlan_id: 20
    state: deleted

# After state:
# ------------
#
# sonic# show Vlan
# Q: A - Access (Untagged), T - Tagged
# NUM        Status      Q Ports
# 10         Inactive
#
# sonic#


# Using "deleted" state

# Before state:
# -------------
#
# sonic# show Vlan
# Q: A - Access (Untagged), T - Tagged
# NUM        Status      Q Ports
# 10         Inactive
# 20         Inactive
# 30         Inactive
#
# sonic#

- name: Deletes all the VLANs on the switch
  dellemc.enterprise_sonic.sonic_vlans:
    config:
    state: deleted

# After state:
# ------------
#
# sonic# show Vlan
# Q: A - Access (Untagged), T - Tagged
# NUM        Status      Q Ports
#
# sonic#

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 is always 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 that is returned is always 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"]

Authors

  • Mohamed Javeed (@javeedf)