junipernetworks.junos.junos_vlans 模块 – VLAN 资源模块
注意
此模块是 junipernetworks.junos 集合(版本 9.1.0)的一部分。
如果您使用的是 ansible
包,则可能已安装此集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install junipernetworks.junos
。您需要其他要求才能使用此模块,请参阅 要求 了解详细信息。
要在 playbook 中使用它,请指定:junipernetworks.junos.junos_vlans
。
junipernetworks.junos 1.0.0 中的新增功能
概要
此模块在 Junos OS 上创建和管理 VLAN 配置。
要求
执行此模块的主机需要以下要求。
ncclient (>=v0.6.4)
参数
参数 |
注释 |
---|---|
Vlan 选项的字典 |
|
VLAN 的文本描述 |
|
逻辑 3 层接口的名称。 |
|
VLAN 的名称。 |
|
VLAN 的 IEEE 802.1q VLAN 标识符 (1..4094)。 |
|
此选项仅在状态为 *parsed* 时使用。 此选项的值应是通过执行命令 show vlans 从 Junos 设备接收的输出。 状态 *parsed* 从 |
|
模块完成后配置的状态。 选择
|
注释
注意
此模块要求在被管理的远程设备上启用 netconf 系统服务
针对 Junos OS 18.4R1 测试
此模块使用连接
netconf
。请参阅 Junos OS 平台选项。
示例
# Using merged
#
# Before state
# ------------
#
# vagrant@vsrx# show vlans
#
# [edit]
- name: Merge provided Junos vlans config with running-config
junipernetworks.junos.junos_vlans:
config:
- name: vlan1
vlan_id: 1
- name: vlan2
vlan_id: 2
l3_interface: irb.12
state: merged
#
# -------------------------
# Module Execution Result
# -------------------------
# "after": [
# {
# "name": "vlan1",
# "vlan_id": 1
# },
# {
# "l3_interface": "irb.12",
# "name": "vlan2",
# "vlan_id": 2
# }
# ],
# "before": [],
# "changed": true,
# "commands": [
# "<nc:vlans xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">"
# "<nc:vlan><nc:name>vlan1</nc:name><nc:vlan-id>1</nc:vlan-id></nc:vlan>"
# "<nc:vlan><nc:name>vlan2</nc:name><nc:vlan-id>2</nc:vlan-id><nc:l3-interface>irb.12</nc:l3-interface>"
# "</nc:vlan></nc:vlans>"
# ]
# After state
# -----------
#
# vagrant@vsrx# show vlans
# vlan1 {
# vlan-id 1;
# }
# vlan2 {
# vlan-id 2;
# l3-interface irb.12;
# }
# Using replaced
#
# Before state
# ------------
#
# vagrant@vsrx# show vlans
# vlan1 {
# vlan-id 1;
# }
# vlan2 {
# vlan-id 2;
# l3-interface irb.12;
# }
- name: Replace Junos vlans running-config with the provided config
junipernetworks.junos.junos_vlans:
config:
- name: vlan1
vlan_id: 11
l3_interface: irb.10
- name: vlan2
vlan_id: 2
state: replaced
# -------------------------
# Module Execution Result
# -------------------------
# "after": [
# {
# "l3_interface": "irb.10",
# "name": "vlan1",
# "vlan_id": 11
# },
# {
# "name": "vlan2",
# "vlan_id": 2
# }
# ],
# "before": [
# {
# "name": "vlan1",
# "vlan_id": 1
# },
# {
# "l3_interface": "irb.12",
# "name": "vlan2",
# "vlan_id": 2
# }
# ],
# "changed": true,
# "commands": [
# "<nc:vlans xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">"
# "<nc:vlan delete="delete"><nc:name>vlan1</nc:name></nc:vlan>"
# "<nc:vlan delete="delete"><nc:name>vlan2</nc:name></nc:vlan>"
# "<nc:vlan><nc:name>vlan1</nc:name><nc:vlan-id>11</nc:vlan-id>"
# "<nc:l3-interface>irb.10</nc:l3-interface></nc:vlan><nc:vlan>"
# "<nc:name>vlan2</nc:name><nc:vlan-id>2</nc:vlan-id></nc:vlan></nc:vlans>"
# ]
# After state
# -----------
#
# vagrant@vsrx# show vlans
# vlan1 {
# vlan-id 11;
# l3-interface irb.10;
# }
# vlan2 {
# vlan-id 2;
# }
#
# Using overridden
#
# Before state
# ------------
#
# vagrant@vsrx# show vlans
# vlan1 {
# vlan-id 11;
# l3-interface irb.10;
# }
# vlan2 {
# vlan-id 2;
# }
- name: Override Junos running-config with provided config
junipernetworks.junos.junos_vlans:
config:
- name: vlan3
vlan_id: 3
l3_interface: irb.13
state: overridden
# -------------------------
# Module Execution Result
# -------------------------
# "after": [
# {
# "l3_interface": "irb.13",
# "name": "vlan3",
# "vlan_id": 3
# }
# ],
# "before": [
# {
# "l3_interface": "irb.10",
# "name": "vlan1",
# "vlan_id": 11
# },
# {
# "name": "vlan2",
# "vlan_id": 2
# }
# ],
# "changed": true,
# "commands": [
# "<nc:vlans xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">"
# "<nc:vlan delete="delete"><nc:name>vlan1</nc:name></nc:vlan><nc:vlan delete="delete">"
# "<nc:name>vlan2</nc:name></nc:vlan><nc:vlan><nc:name>vlan3</nc:name><nc:vlan-id>3</nc:vlan-id>"
# "<nc:l3-interface>irb.13</nc:l3-interface></nc:vlan></nc:vlans>"
# ]
# After state
# -----------
#
# vagrant@vsrx# show vlans
# vlan3 {
# vlan-id 3;
# l3-interface irb.13;
# }
#
# Using deleted
#
# Before state
# ------------
#
# vagrant@vsrx# show vlans
# vlan3 {
# vlan-id 3;
# l3-interface irb.13;
# }
- name: Delete specific vlan
junipernetworks.junos.junos_vlans:
config:
- name: vlan3
state: deleted
# -------------------------
# Module Execution Result
# -------------------------
# "after": [],
# "changed": true,
# "commands": [
# "<nc:vlans xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
# "<nc:vlan delete="delete"><nc:name>vlan3</nc:name></nc:vlan></nc:vlans>"
# ]
# After state
# -----------
#
# vagrant@vsrx# show vlans
# vlan1 {
# vlan-id 11;
# l3-interface irb.10;
# }
# vlan2 {
# vlan-id 2;
# }
- name: Gather running vlans configuration
junipernetworks.junos.junos_vlans:
state: gathered
#
# -------------------------
# Module Execution Result
# -------------------------
# "gathered": [
# {
# "l3_interface": "irb.10",
# "name": "vlan1",
# "vlan_id": 11
# },
# {
# "name": "vlan2",
# "vlan_id": 2
# }
# ],
# "changed": false,
#
# Using rendered
#
# Before state
# ------------
#
- name: Render xml for provided facts.
junipernetworks.junos.junos_vlans:
config:
- name: vlan1
vlan_id: 1
- name: vlan2
vlan_id: 2
l3_interface: irb.12
state: rendered
#
# -------------------------
# Module Execution Result
# -------------------------
# "rendered": [
# "<nc:vlans xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">"
# "<nc:vlan><nc:name>vlan1</nc:name><nc:vlan-id>1</nc:vlan-id></nc:vlan>"
# "<nc:vlan><nc:name>vlan2</nc:name><nc:vlan-id>2</nc:vlan-id><nc:l3-interface>irb.12</nc:l3-interface>"
# "</nc:vlan></nc:vlans>"
# ]
# Using parsed
# parsed.cfg
# ------------
# <?xml version="1.0" encoding="UTF-8"?>
# <rpc-reply message-id="urn:uuid:0cadb4e8-5bba-47f4-986e-72906227007f">
# <configuration changed-seconds="1590139550" changed-localtime="2020-05-22 09:25:50 UTC">
# <version>18.4R1-S2.4</version>
# <vlans>
# <vlan>
# <name>vlan1</name>
# <vlan-id>1</vlan-id>
# </vlan>
# <vlan>
# <name>vlan2</name>
# <vlan-id>2</vlan-id>
# <l3-interface>irb.12</l3-interface>
# </vlan>
# </vlans>
# </configuration>
# </rpc-reply>
- name: Parse routing instance running config
junipernetworks.junos.junos_vlans:
running_config: "{{ lookup('file', './parsed.cfg') }}"
state: parsed
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
#
# "parsed": [
# {
# "name": "vlan1",
# "vlan_id": 1
# },
# {
# "l3_interface": "irb.12",
# "name": "vlan2",
# "vlan_id": 2
# }
# ]
#
返回值
常见的返回值在此处记录,以下是此模块特有的字段
键 |
描述 |
---|---|
模块完成后,配置作为结构化数据。 已返回:当发生更改时 示例: |
|
调用模块之前,配置作为结构化数据。 已返回:始终 示例: |
|
推送到远程设备的命令集。 已返回:始终 示例: |