ansible.builtin.nxos_vlan (v2.7.16) — module

Manages VLAN resources and attributes.

| "added in version" 2.1 of ansible.builtin"

Authors: Jason Edelman (@jedelman8)

preview | supported by network

Install Ansible via pip

Install with pip install ansible==2.7.16

Description

Manages VLAN configurations on NX-OS switches.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Ensure a range of VLANs are not present on the switch
  nxos_vlan:
    vlan_range: "2-10,20,50,55-60,100-150"
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Ensure VLAN 50 exists with the name WEB and is in the shutdown state
  nxos_vlan:
    vlan_id: 50
    admin_state: down
    name: WEB
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Ensure VLAN is NOT on the device
  nxos_vlan:
    vlan_id: 50
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add interfaces to VLAN and check intent (config + intent)
  nxos_vlan:
    vlan_id: 100
    interfaces:
      - Ethernet2/1
      - Ethernet2/5
    associated_interfaces:
      - Ethernet2/1
      - Ethernet2/5
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Check interfaces assigned to VLAN
  nxos_vlan:
    vlan_id: 100
    associated_interfaces:
      - Ethernet2/1
      - Ethernet2/5
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create aggregate of vlans
  nxos_vlan:
    aggregate:
      - { vlan_id: 4000, mode: ce }
      - { vlan_id: 4001, name: vlan-4001 }
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: purge vlans - removes all other vlans except the ones mentioned in aggregate)
  nxos_vlan:
    aggregate:
      - vlan_id: 1
      - vlan_id: 4001
    purge: yes

Inputs

    
mode:
    choices:
    - ce
    - fabricpath
    description:
    - Set VLAN mode to classical ethernet or fabricpath. This is a valid option for Nexus
      5000 and 7000 series.
    version_added: '2.4'
    version_added_collection: ansible.builtin

name:
    description:
    - Name of VLAN or keyword 'default'.

delay:
    default: 10
    description:
    - Time in seconds to wait before checking for the operational state on remote device.
      This wait is applicable for operational state arguments.

purge:
    default: 'no'
    description:
    - Purge VLANs not defined in the I(aggregate) parameter. This parameter can be used
      without aggregate as well.
    type: bool

state:
    choices:
    - present
    - absent
    default: present
    description:
    - Manage the state of the resource.

vlan_id:
    description:
    - Single VLAN ID.

aggregate:
    description: List of VLANs definitions.
    version_added: '2.5'
    version_added_collection: ansible.builtin

interfaces:
    description:
    - List of interfaces that should be associated to the VLAN or keyword 'default'.
    version_added: '2.5'
    version_added_collection: ansible.builtin

mapped_vni:
    description:
    - The Virtual Network Identifier (VNI) ID that is mapped to the VLAN. Valid values
      are integer and keyword 'default'. Range 4096-16773119.
    version_added: '2.2'
    version_added_collection: ansible.builtin

vlan_range:
    description:
    - Range of VLANs such as 2-10 or 2,5,10-15, etc.

vlan_state:
    choices:
    - active
    - suspend
    default: active
    description:
    - Manage the vlan operational state of the VLAN

admin_state:
    choices:
    - up
    - down
    default: up
    description:
    - Manage the VLAN administrative state of the VLAN equivalent to shut/no shut in VLAN
      config mode.

associated_interfaces:
    description:
    - This is a intent option and checks the operational state of the for given vlan C(name)
      for associated interfaces. If the value in the C(associated_interfaces) does not
      match with the operational state of vlan interfaces on device it will result in
      failure.
    version_added: '2.5'
    version_added_collection: ansible.builtin

Outputs

commands:
  description: Set of command strings to send to the remote device
  returned: always
  sample:
  - vlan 20
  - vlan 55
  - vn-segment 5000
  type: list