arista.eos.eos_interfaces 模块 – 接口资源模块
注意
此模块是 arista.eos 集合(版本 10.0.1)的一部分。
如果您正在使用 ansible
包,您可能已经安装了此集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install arista.eos
。
要在 playbook 中使用它,请指定:arista.eos.eos_interfaces
。
arista.eos 1.0.0 中的新增功能
概要
此模块管理 Arista EOS 接口的接口属性。
参数
参数 |
注释 |
---|---|
提供的配置 |
|
接口描述 |
|
接口链路状态。仅适用于以太网接口。 除 当 speed 设置为高于 |
|
接口的管理状态。 将该值设置为 选项
|
|
管理接口的第 2 层或第 3 层状态。仅适用于以太网和端口通道接口。 选项
|
|
特定接口的 MTU。必须是介于 576 和 9216 之间的偶数。仅适用于以太网接口。 |
|
接口的全名,例如 GigabitEthernet1。 |
|
接口链路速度。仅适用于以太网接口。 |
|
此选项仅与状态 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
# !
# interface Management1
# ip address dhcp
# dhcp client accept default-route
- name: Merge provided configuration with device configuration
arista.eos.eos_interfaces:
config:
- name: Ethernet1
enabled: true
mode: layer3
- name: Ethernet2
description: Configured by Ansible
enabled: false
state: merged
# Task Output
# -----------
#
# before:
# - enabled: true
# name: Ethernet1
# - enabled: true
# name: Ethernet2
# - enabled: true
# name: Management1
# commands:
# - interface Ethernet1
# - no switchport
# - interface Ethernet2
# - shutdown
# - description Configured by Ansible
# after:
# - enabled: true
# mode: layer3
# name: Ethernet1
# - description: Configured by Ansible
# enabled: false
# name: Ethernet2
# - enabled: true
# name: Management1
# After state:
# ------------
#
# test#show running-config | section interface
# interface Ethernet1
# no switchport
# !
# interface Ethernet2
# description Configured by Ansible
# shutdown
# !
# interface Management1
# ip address dhcp
# dhcp client accept default-route
# Using replaced
# Before state:
# -------------
#
# test#show running-config | section interface
# interface Ethernet1
# no switchport
# !
# interface Ethernet2
# description Configured by Ansible
# shutdown
# !
# interface Management1
# ip address dhcp
# dhcp client accept default-route
- name: Replaces device configuration of listed interfaces with provided configuration
arista.eos.eos_interfaces:
config:
- name: Ethernet1
enabled: true
- name: Ethernet2
description: Configured by Ansible
enabled: false
state: replaced
# Task Output
# -----------
#
# before:
# - enabled: true
# mode: layer3
# name: Ethernet1
# - description: Configured by Ansible
# enabled: false
# name: Ethernet2
# - enabled: true
# name: Management1
# commands:
# - interface Ethernet1
# - switchport
# after:
# - enabled: true
# name: Ethernet1
# - description: Configured by Ansible
# enabled: false
# name: Ethernet2
# - enabled: true
# 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 overridden
# 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: Overrides all device configuration with provided configuration
arista.eos.eos_interfaces:
config:
- name: Ethernet1
enabled: true
- name: Ethernet2
description: Configured by Ansible
enabled: false
state: overridden
# Task Output
# -----------
#
# before:
# - enabled: true
# name: Ethernet1
# - description: Configured by Ansible
# enabled: false
# name: Ethernet2
# - enabled: true
# name: Management1
# commands:
# - interface Management1
# - no shutdown
# after:
# - enabled: true
# name: Ethernet1
# - description: Configured by Ansible
# enabled: false
# name: Ethernet2
# - enabled: true
# 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 deleted
# 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: Delete or return interface parameters to default settings
arista.eos.eos_interfaces:
config:
- name: Ethernet1
state: deleted
# Task Output
# -----------
#
# before:
# - enabled: true
# name: Ethernet1
# - description: Configured by Ansible
# enabled: false
# name: Ethernet2
# - enabled: true
# name: Management1
# commands:
# - interface Ethernet1
# - no shutdown
# after:
# - enabled: true
# name: Ethernet1
# - description: Configured by Ansible
# enabled: false
# name: Ethernet2
# - enabled: true
# 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: Render the provided configuration into platform specific configuration lines
arista.eos.eos_interfaces:
config:
- name: Ethernet1
enabled: true
mode: layer3
- name: Ethernet2
description: Configured by Ansible
enabled: false
state: rendered
# Module Execution Result:
# ------------------------
#
# rendered:
# - interface Ethernet1
# - no shutdown
# - no switchport
# - interface Ethernet2
# - shutdown
# - description Configured by Ansible
# Using Parsed
# File: parsed.cfg
# ----------------
#
# interface Ethernet1
# description "Interface 1"
# !
# interface Ethernet2
# description "Configured by Ansible"
# shutdown
# !
- name: Parse the commands for provided configuration
arista.eos.interfaces:
running_config: "{{ lookup('file', 'parsed.cfg') }}"
state: parsed
# Module Execution Result:
# ------------------------
#
# parsed:
# - name: Ethernet1
# enabled: True
# mode: layer2
# - name: Ethernet2
# description: 'Configured by Ansible'
# enabled: False
# mode: layer2
# Using Gathered
# 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: Gather interfaces facts from the device
arista.eos.interfaces:
state: gathered
# Module Execution Result:
# ------------------------
#
# gathered:
# - enabled: true
# name: Ethernet1
# - description: Configured by Ansible
# enabled: false
# name: Ethernet2
# - enabled: true
# name: Management1
返回值
常见的返回值记录在 此处,以下是此模块独有的字段
键 |
描述 |
---|---|
模块执行后的结果配置。 返回: 当已更改时 示例: |
|
模块执行之前的配置。 返回:当 state 为 示例: |
|
推送到远程设备的一组命令。 返回:当 state 为 示例: |
|
以结构化数据形式从远程设备收集的网络资源的事实。 返回:当 state 为 示例: |
|
根据模块参数规范将 running_config 选项中提供的设备原生配置解析为结构化数据。 返回:当 state 为 示例: |
|
任务中提供的配置以设备原生格式呈现(离线)。 返回:当 state 为 示例: |