junos_vlans – Create and manage VLAN configurations on Junos OS

New in version 2.9.

Synopsis

  • This module creates and manages VLAN configurations on Junos OS.

Requirements

The below requirements are needed on the host that executes this module.

  • ncclient (>=v0.6.4)

Parameters

Parameter Choices/Defaults Comments
config
list / elements=dictionary
A dictionary of Vlan options
description
string
Text description of VLANs
name
string / required
Name of VLAN.
vlan_id
integer / required
IEEE 802.1q VLAN identifier for VLAN (1..4094).
state
string
    Choices:
  • merged ←
  • replaced
  • overridden
  • deleted
The state of the configuration after module completion.

Notes

Note

  • This module requires the netconf system service be enabled on the remote device being managed

  • Tested against Junos OS 18.4R1

  • This module works with connection netconf. See the Junos OS Platform Options.

Examples

# Using merged
#############

# Before State
# ------------
#
# admin# show vlans
# vlan-2 {
#     vlan-id 2;
# }
# vlan-3 {
#     vlan-id 3;
# }

- name: Merge JUNOS vlan
  junos_vlans:
    config:
      - name: vlan-1
        vlan-id: 1
  state: merged

# After State
# -----------
#
# admin# show vlans
# vlan-1 {
#     vlan-id 1;
# }
# vlan-2 {
#     vlan-id 2;
# }
# vlan-3 {
#     vlan-id 3;
# }


# Using replaced
################

# Before State
# ------------
#
# admin# show vlans
# vlan-1 {
#     vlan-id 1;
# }
# vlan-2 {
#     vlan-id 2;
# }
# vlan-3 {
#     vlan-id 3;
# }

- name: Replace JUNOS vlan
  junos_vlans:
    config:
      - name: vlan-1
        vlan-id: 10
      - name: vlan-3
        vlan-id: 30
  state: replaced

# After State
# -----------
#
# admin# show vlans
# vlan-1 {
#     vlan-id 10;
# }
# vlan-2 {
#     vlan-id 2;
# }
# vlan-3 {
#     vlan-id 30;
# }


# Using overridden
##################

# Before State
# ------------
#
# admin# show vlans
# vlan-1 {
#     vlan-id 1;
# }
# vlan-2 {
#     vlan-id 2;
# }
# vlan-3 {
#     vlan-id 3;
# }

- name: Override JUNOS vlan
  junos_vlans:
    config:
      - name: vlan-4
        vlan-id: 100
      - name: vlan-2
        vlan-id: 200
  state: overridden

# After State
# -----------
#
# admin# show vlans
# vlan-2 {
#     vlan-id 200;
# }
# vlan-4 {
#     vlan-id 100;
# }


#Using deleted
##############

# Before State
# ------------
#
# admin# show vlans
# vlan-1 {
#     vlan-id 1;
# }
# vlan-2 {
#     vlan-id 2;
# }
# vlan-3 {
#     vlan-id 3;
# }

- name: Delete JUNOS vlan
  junos_vlans:
    config:
      - name: vlan-1
  state: deleted

# After State
# -----------
#
# admin# show vlans
# vlan-2 {
#     vlan-id 2;
# }
# vlan-3 {
#     vlan-id 3;
# }

Return Values

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

Key Returned Description
after
string
when changed
The configuration as structured data after module completion.

Sample:
The configuration returned will always be in the same format of the parameters above.
before
string
always
The configuration as structured data prior to module invocation.

Sample:
The configuration returned will always be in the same format of the parameters above.
commands
list
always
The set of commands pushed to the remote device.

Sample:
['xml 1', 'xml 2', 'xml 3']


Status

Red Hat Support

More information about Red Hat’s support of this module is available from this Red Hat Knowledge Base article.

Authors

  • Daniel Mellado (@danielmellado)

Hint

If you notice any issues in this documentation, you can edit this document to improve it.