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 接口的接口属性。

参数

参数

注释

config

列表 / 元素=字典

提供的配置

description

字符串

接口描述

duplex

字符串

接口链路状态。仅适用于以太网接口。

auto 之外的值还必须设置 speed

speed 设置高于 1000 时被忽略。

enabled

布尔值

接口的管理状态。

将值设置为 true 以在管理上启用接口,或设置为 false 以禁用它。

选项

  • false

  • true ← (默认)

mode

字符串

管理接口的二层或三层状态。仅适用于以太网和端口通道接口。

选项

  • "layer2"

  • "layer3"

mtu

整数

特定接口的 MTU。必须是 576 到 9216 之间的偶数。仅适用于以太网接口。

name

字符串 / 必需

接口的全名,例如 GigabitEthernet1。

speed

字符串

接口链路速度。仅适用于以太网接口。

running_config

字符串

此选项仅与 state parsed 一起使用。

此选项的值应是从 EOS 设备执行命令 show running-config | section ^interface 收到的输出。

state parsedrunning_config 选项读取配置并将其转换为 Ansible 结构化数据,该值随后在结果中的 parsed 密钥中返回。

state

字符串

模块完成后的配置状态。

选项

  • "merged" ← (默认)

  • "replaced"

  • "overridden"

  • "deleted"

  • "parsed"

  • "rendered"

  • "gathered"

备注

注意

示例

# 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

返回值

常见的返回值已在此处记录 此处,以下是此模块独有的字段

描述

after

字典

模块执行后的最终配置。

返回:发生更改时

示例:"This output will always be in the same format as the module argspec.\n"

before

字典

模块执行之前的配置。

返回:statemergedreplacedoverriddendeletedpurged

示例:"This output will always be in the same format as the module argspec.\n"

commands

列表 / 元素=字符串

推送到远程设备的命令集。

返回:statemergedreplacedoverriddendeletedpurged

示例:["interface Ethernet1", "no shutdown", "no switchport"]

gathered

列表 / 元素=字符串

从远程设备收集的网络资源信息,以结构化数据形式呈现。

返回:stategathered

示例:["This output will always be in the same format as the module argspec.\n"]

parsed

列表 / 元素=字符串

根据模块 argspec 将 running_config 选项中提供的设备原生配置解析为结构化数据。

返回:stateparsed

示例:["This output will always be in the same format as the module argspec.\n"]

rendered

列表 / 元素=字符串

以设备原生格式呈现的任务中提供的配置(离线)。

返回:staterendered

示例:["interface Ethernet1", "no shutdown", "no switchport"]

作者

  • Nathaniel Case (@Qalthos)