arista.eos.eos_l2_interfaces 模块 – L2 接口资源模块
注意
此模块是 arista.eos 集合 (版本 10.0.1) 的一部分。
如果您使用的是 ansible
包,则可能已经安装了此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install arista.eos
。
要在 playbook 中使用它,请指定:arista.eos.eos_l2_interfaces
。
arista.eos 1.0.0 中的新增功能
概要
此模块提供对 Arista EOS 设备上的第 2 层接口的声明式管理。
参数
参数 |
注释 |
---|---|
第 2 层接口选项的字典 |
|
Switchport mode access 命令,用于将接口配置为第 2 层接入端口。 |
|
在接入端口中配置给定的 VLAN。它用作接入 VLAN ID。 |
|
需要配置接口的模式。 接入模式未显示在接口事实中,因此对于 switchport mode access,不会保持幂等性,每次输出都将显示为 changed=True。 选项
|
|
接口的全名,例如 Ethernet1。 |
|
Switchport mode trunk 命令,用于将接口配置为第 2 层 trunk 端口。 |
|
要在 trunk 端口中配置的本机 VLAN。它用作 trunk 本机 VLAN ID。 |
|
给定 trunk 端口中允许的 VLAN 列表。这些是将在 trunk 上配置的唯一 VLAN。 |
|
此选项仅与 state parsed 一起使用。 此选项的值应为通过执行命令 **show running-config | section ^interface** 从 EOS 设备接收的输出。 state parsed 从 |
|
模块完成后的配置状态 选项
|
备注
注意
针对 Arista EOS 4.24.6F 进行测试
此模块适用于连接
network_cli
。参见 https://docs.ansible.org.cn/ansible/latest/network/user_guide/platform_eos.html
示例
# Using merged
# Before state:
# -------------
#
# test#show running-config | section interface
# interface Ethernet1
# !
# interface Ethernet2
# description Configured by Ansible
# shutdown
# !
# interface Management1
# ip address dhcp
# dhcp client accept default-route
- name: Merge provided configuration with device configuration.
arista.eos.eos_l2_interfaces:
config:
- name: Ethernet1
mode: trunk
trunk:
native_vlan: 10
- name: Ethernet2
mode: access
access:
vlan: 30
state: merged
# Task Output
# -----------
#
# before:
# - name: Ethernet1
# - name: Ethernet2
# - name: Management1
# commands:
# - interface Ethernet1
# - switchport mode trunk
# - switchport trunk native vlan 10
# - interface Ethernet2
# - switchport mode access
# - switchport access vlan 30
# after:
# - mode: trunk
# name: Ethernet1
# trunk:
# native_vlan: 10
# - access:
# vlan: 30
# name: Ethernet2
# - name: Management1
# After state:
# ------------
#
# test#show running-config | section interface
# interface Ethernet1
# switchport trunk native vlan 10
# switchport mode trunk
# !
# interface Ethernet2
# description Configured by Ansible
# shutdown
# switchport access vlan 30
# !
# interface Management1
# ip address dhcp
# dhcp client accept default-route
# Using replaced
# Before state:
# -------------
#
# test#show running-config | section interface
# interface Ethernet1
# switchport trunk native vlan 10
# switchport mode trunk
# !
# interface Ethernet2
# description Configured by Ansible
# shutdown
# switchport access vlan 30
# !
# interface Management1
# ip address dhcp
# dhcp client accept default-route
- name: Replace device configuration of specified L2 interfaces with provided configuration.
arista.eos.eos_l2_interfaces:
config:
- name: Ethernet1
mode: trunk
trunk:
native_vlan: 20
trunk_allowed_vlans: 5-10, 15
state: replaced
# Task Output
# -----------
#
# before:
# - mode: trunk
# name: Ethernet1
# trunk:
# native_vlan: 10
# - access:
# vlan: 30
# name: Ethernet2
# - name: Management1
# commands:
# - interface Ethernet1
# - switchport trunk native vlan 20
# - switchport trunk allowed vlan 10,15,5,6,7,8,9
# after:
# - mode: trunk
# name: Ethernet1
# trunk:
# native_vlan: 20
# trunk_allowed_vlans:
# - 5-10
# - '15'
# - access:
# vlan: 30
# name: Ethernet2
# - name: Management1
# After state:
# ------------
#
# test#show running-config | section interface
# interface Ethernet1
# switchport trunk native vlan 20
# switchport trunk allowed vlan 5-10,15
# switchport mode trunk
# !
# interface Ethernet2
# description Configured by Ansible
# shutdown
# switchport access vlan 30
# !
# interface Management1
# ip address dhcp
# dhcp client accept default-route
# Using overridden
# Before state:
# -------------
#
# test#show running-config | section interface
# interface Ethernet1
# switchport trunk native vlan 20
# switchport trunk allowed vlan 5-10,15
# switchport mode trunk
# !
# interface Ethernet2
# description Configured by Ansible
# shutdown
# switchport access vlan 30
# !
# interface Management1
# ip address dhcp
# dhcp client accept default-route
- name: Override device configuration of all L2 interfaces on device with provided
configuration.
arista.eos.eos_l2_interfaces:
config:
- name: Ethernet2
mode: access
access:
vlan: 30
state: overridden
# Task Output
# -----------
#
# before:
# - mode: trunk
# name: Ethernet1
# trunk:
# native_vlan: 20
# trunk_allowed_vlans:
# - 5-10
# - '15'
# - access:
# vlan: 30
# name: Ethernet2
# - name: Management1
# commands:
# - interface Ethernet1
# - no switchport mode
# - no switchport trunk allowed vlan
# - no switchport trunk native vlan
# - interface Ethernet2
# - switchport mode access
# after:
# - name: Ethernet1
# - access:
# vlan: 30
# name: Ethernet2
# - name: Management1
# After state:
# ------------
#
# test#show running-config | section interface
# interface Ethernet1
# !
# interface Ethernet2
# description Configured by Ansible
# shutdown
# switchport access vlan 30
# !
# interface Management1
# ip address dhcp
# dhcp client accept default-route
# Using deleted
# Before state:
# -------------
#
# test#show running-config | section interface
# interface Ethernet1
# !
# interface Ethernet2
# description Configured by Ansible
# shutdown
# switchport access vlan 30
# !
# interface Management1
# ip address dhcp
# dhcp client accept default-route
- name: Delete EOS L2 interfaces as in given arguments.
arista.eos.eos_l2_interfaces:
config:
- name: Ethernet1
- name: Ethernet2
state: deleted
# Task Output
# -----------
#
# before:
# - name: Ethernet1
# - access:
# vlan: 30
# name: Ethernet2
# - name: Management1
# commands:
# - interface Ethernet2
# - no switchport access vlan
# after:
# - name: Ethernet1
# - name: Ethernet2
# - name: Management1
# After state:
# ------------
#
# test#show running-config | section interface
# interface Ethernet1
# !
# interface Ethernet2
# description Configured by Ansible
# shutdown
# !
# interface Management1
# ip address dhcp
# dhcp client accept default-route
# using rendered
- name: Use Rendered to convert the structured data to native config
arista.eos.eos_l2_interfaces:
config:
- name: Ethernet1
mode: trunk
trunk:
native_vlan: 10
- name: Ethernet2
mode: access
access:
vlan: 30
state: rendered
# Module Execution Result:
# ------------------------
#
# rendered:
# - interface Ethernet1
# - switchport mode trunk
# - switchport trunk native vlan 10
# - interface Ethernet2
# - switchport mode access
# - switchport access vlan 30
# Using parsed
# File: parsed.cfg
# ----------------
#
# interface Ethernet1
# switchport trunk native vlan 10
# switchport mode trunk
# !
# interface Ethernet2
# switchport access vlan 30
# !
- name: Parse the commands for provided configuration
arista.eos.l2_interfaces:
running_config: "{{ lookup('file', 'parsed.cfg') }}"
state: parsed
# Module Execution Result:
# ------------------------
#
# parsed:
# - name: Ethernet1
# mode: trunk
# trunk:
# native_vlan: 10
# - name: Ethernet2
# mode: access
# access:
# vlan: 30
# Using gathered
# Before state:
# -------------
#
# veos#show running-config | section interface
# interface Ethernet1
# switchport trunk native vlan 10
# switchport mode trunk
# !
# interface Ethernet2
# switchport access vlan 30
# !
- name: Gather interfaces facts from the device
arista.eos.l2_interfaces:
state: gathered
# Module Execution Result:
# ------------------------
#
# gathered:
# - name: Ethernet1
# mode: trunk
# trunk:
# native_vlan: 10
# - name: Ethernet2
# mode: access
# access:
# vlan: 30
返回值
常见的返回值已记录在 此处,以下是此模块特有的字段
键 |
描述 |
---|---|
模块执行后的结果配置。 返回:发生更改时 示例: |
|
模块执行前的配置。 返回:当 state 为 示例: |
|
推送到远程设备的命令集。 返回:当 state 为 示例: |
|
从远程设备收集到的关于网络资源的事实,以结构化数据的形式呈现。 返回:当 state 为 示例: |
|
根据模块参数规范(argspec),在running_config选项中提供的设备原生配置被解析成结构化数据。 返回:当state为 示例: |
|
任务中提供的配置以设备原生格式(离线)进行渲染。 返回:当state为 示例: |