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 设备上二层接口的声明式管理。
参数
参数 |
注释 |
---|---|
二层接口选项的字典 |
|
将接口配置为二层访问的交换机端口模式访问命令。 |
|
在访问端口中配置给定的 VLAN。它用作访问 VLAN ID。 |
|
需要配置接口的模式。 访问模式不显示在接口事实中,因此不会保持交换机端口模式访问的幂等性,并且每次输出都会显示为 changed=True。 选择
|
|
接口的全名,例如 Ethernet1。 |
|
将接口配置为二层 trunk 的交换机端口模式 trunk 命令。 |
|
要在 trunk 端口中配置的本机 VLAN。它用作 trunk 本机 VLAN ID。 |
|
给定 trunk 端口中允许的 VLAN 列表。这些是将仅在 trunk 上配置的 VLAN。 |
|
此选项仅与状态 *parsed* 一起使用。 此选项的值应是通过执行命令 **show running-config | section ^interface** 从 EOS 设备收到的输出。 状态 *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
返回值
通用返回值记录在 此处,以下是此模块特有的字段
键 |
描述 |
---|---|
模块执行后的结果配置。 返回:当 changed 时 示例: |
|
模块执行之前的配置。 返回:当 state 为 示例: |
|
推送到远程设备的命令集。 返回:当 state 为 示例: |
|
从远程设备收集的关于网络资源的结构化数据的事实。 返回:当 state 为 示例: |
|
running_config 选项中提供的设备原生配置根据模块 argspec 解析为结构化数据。 返回: 当 state 为 示例: |
|
任务中提供的配置以设备原生格式渲染(离线)。 返回: 当 state 为 示例: |