arista.eos.eos_l3_interfaces 模块 – L3 接口资源模块

注意

此模块是 arista.eos 集合(版本 10.0.1)的一部分。

如果您使用的是 ansible 包,则可能已安装此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用: ansible-galaxy collection install arista.eos

要在剧本中使用它,请指定: arista.eos.eos_l3_interfaces

arista.eos 1.0.0 中的新增功能

概要

  • 此模块提供对 Arista EOS 设备上的三层接口的声明式管理。

参数

参数

注释

config

列表 / 元素=字典

三层接口选项的字典

ipv4

列表 / 元素=字典

要在 _name_ 选项中提到的三层接口上设置的 IPv4 地址列表。

address

字符串

要设置的 IPv4 地址,格式为 /<掩码>,例如 192.0.2.1/24,或者 dhcp 用于查询 DHCP 获取 IP 地址。

secondary

布尔值

此地址是否为辅助地址。

选项

  • false

  • true

virtual

布尔值

此地址是否为虚拟地址。

选项

  • false

  • true

ipv6

列表 / 元素=字典

要在 _name_ 选项中提到的三层接口上设置的 IPv6 地址列表。

address

字符串

要设置的 IPv6 地址,地址格式为 /<掩码>,例如 2001:db8:2201:1::1/64 或 auto-config 用于使用 SLAAC 选择地址。

name

字符串 / 必需

接口的全名,即 Ethernet1。

running_config

字符串

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

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

state _parsed_ 从 running_config 选项读取配置并将其转换为 Ansible 结构化数据,然后根据资源模块的 argspec 将其值返回到结果中的 _parsed_ 键中。

state

字符串

模块完成后的配置状态

选项

  • "merged" ← (默认)

  • "replaced"

  • "overridden"

  • "deleted"

  • "parsed"

  • "gathered"

  • "rendered"

备注

注意

示例

# 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_l3_interfaces:
    config:
      - name: Ethernet1
        ipv4:
          - address: 198.51.100.14/24
      - name: Ethernet2
        ipv4:
          - address: 203.0.113.27/24
    state: merged

# Task Output
# -----------
#
# before:
# - name: Ethernet1
# - name: Ethernet2
# - ipv4:
#   - address: dhcp
#   name: Management1
# commands:
# - interface Ethernet1
# - ip address 198.51.100.14/24
# - interface Ethernet2
#   - ip address 203.0.113.27/24
# after:
# - ipv4:
#   - address: 198.51.100.14/24
#   name: Ethernet1
# - ipv4:
#   - address: 203.0.113.27/24
#   name: Ethernet2
# - ipv4:
#   - address: dhcp
#   name: Management1

# After state:
# ------------
#
# test#show running-config | section interface
# interface Ethernet1
#    ip address 198.51.100.14/24
# !
# interface Ethernet2
#    description Configured by Ansible
#    shutdown
#    ip address 203.0.113.27/24
# !
# interface Management1
#    ip address dhcp
#    dhcp client accept default-route

# Using overridden

# Before state:
# -------------
#
# test#show running-config | section interface
# interface Ethernet1
#    ip address 198.51.100.14/24
# !
# interface Ethernet2
#    ip address 203.0.113.27/24
# !
# 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_l3_interfaces:
    config:
      - name: Ethernet1
        ipv6:
          - address: 2001:db8:feed::1/96
      - name: Ethernet2
        ipv4:
          - address: 203.0.113.27/24
      - ipv4:
          - address: dhcp
        name: Management1
    state: overridden

# Task Output
# -----------
#
# before:
# - ipv4:
#   - address: 198.51.100.14/24
#   name: Ethernet1
# - ipv4:
#   - address: 203.0.113.27/24
#   name: Ethernet2
# - ipv4:
#   - address: dhcp
#   name: Management1
# commands:
# - interface Ethernet1
# - ipv6 address 2001:db8:feed::1/96
# - no ip address
# after:
# - ipv6:
#   - address: 2001:db8:feed::1/96
#   name: Ethernet1
# - ipv4:
#   - address: 203.0.113.27/24
#   name: Ethernet2
# - ipv4:
#   - address: dhcp
#   name: Management1

# After state:
# ------------
#
# test#show running-config | section interface
# interface Ethernet1
#    ipv6 address 2001:db8:feed::1/96
# !
# interface Ethernet2
#    ip address 203.0.113.27/24
# !
# interface Management1
#    ip address dhcp
#    dhcp client accept default-route

# Using replaced

# Before state:
# -------------
#
# test#show running-config | section interface
# interface Ethernet1
#    ipv6 address 2001:db8:feed::1/96
# !
# interface Ethernet2
#    ip address 203.0.113.27/24
# !
# interface Management1
#    ip address dhcp
#    dhcp client accept default-route

- name: Replace device configuration of specified L2 interfaces with provided configuration.
  arista.eos.eos_l3_interfaces:
    config:
      - name: Ethernet2
        ipv4:
          - address: 203.0.113.27/24
    state: replaced

# Task Output
# -----------
#
# before:
# - ipv6:
#   - address: 2001:db8:feed::1/96
#   name: Ethernet1
# - ipv4:
#   - address: 203.0.113.27/24
#   name: Ethernet2
# - ipv4:
#   - address: dhcp
#   name: Management1
# commands:
# - interface Ethernet2
# - ip address 203.0.113.28/24
# after:
# - ipv6:
#   - address: 2001:db8:feed::1/96
#   name: Ethernet1
# - ipv4:
#   - address: 203.0.113.28/24
#   name: Ethernet2
# - ipv4:
#   - address: dhcp
#   name: Management1

# After state:
# ------------
#
# test#show running-config | section interface
# interface Ethernet1
#    ipv6 address 2001:db8:feed::1/96
# !
# interface Ethernet2
#    ip address 203.0.113.28/24
# !
# interface Management1
#    ip address dhcp
#    dhcp client accept default-route

# Using deleted

# Before state:
# -------------
#
# test#show running-config | section interface
# interface Ethernet1
#    ipv6 address 2001:db8:feed::1/96
# !
# interface Ethernet2
#    ip address 203.0.113.28/24
# !
# interface Management1
#    ip address dhcp
#    dhcp client accept default-route

- name: Delete L3 attributes of given interfaces.
  arista.eos.eos_l3_interfaces:
    config:
      - name: Ethernet1
      - name: Ethernet2
    state: deleted

# Task Output
# -----------
#
# before:
# - ipv6:
#   - address: 2001:db8:feed::1/96
#   name: Ethernet1
# - ipv4:
#   - address: 203.0.113.28/24
#   name: Ethernet2
# - ipv4:
#   - address: dhcp
#   name: Management1
# commands:
# - interface Ethernet1
# - no ipv6 address 2001:db8:feed::1/96
# - interface Ethernet2
# - no ip address
# after:
# - name: Ethernet1
# - name: Ethernet2
# - ipv4:
#   - address: dhcp
#   name: Management1

# After state:
# ------------
#
# test#show running-config | section interface
# interface Ethernet1
# !
# interface Ethernet2
# !
# interface Management1
#    ip address dhcp
#    dhcp client accept default-route

# Using Parsed

# File: parsed.cfg
# ----------------
#
# veos#show running-config | section interface
# interface Ethernet1
#    ip address 198.51.100.14/24
# !
# interface Ethernet2
#    ip address 203.0.113.27/24
# !

- name: Use parsed to convert native configs to structured data
  arista.eos.interfaces:
    running_config: "{{ lookup('file', 'parsed.cfg') }}"
    state: parsed

# Module Execution Result:
# ------------------------
#
# parsed:
#  - name: Ethernet1
#    ipv4:
#      - address: 198.51.100.14/24
#  - name: Ethernet2
#    ipv4:
#      - address: 203.0.113.27/24

# Using rendered:

- name: Use Rendered to convert the structured data to native config
  arista.eos.eos_l3_interfaces:
    config:
      - name: Ethernet1
        ipv4:
          - address: 198.51.100.14/24
      - name: Ethernet2
        ipv4:
          - address: 203.0.113.27/24
    state: rendered

# Module Execution Result:
# ------------------------
#
# rendered:
# - interface Ethernet1
# - ip address 198.51.100.14/24
# - interface Ethernet2
# - ip address 203.0.113.27/24

# using gathered:

# Before state:
# -------------
#
# test#show running-config | section interface
# interface Ethernet1
#    ip address 198.51.100.14/24
# !
# interface Ethernet2
#    ip address 203.0.113.27/24
# !

- name: Gather l3 interfaces facts from the device
  arista.eos.l3_interfaces:
    state: gathered

# Module Execution Result:
# ------------------------
#
# gathered:
#  - name: Ethernet1
#    ipv4:
#      - address: 198.51.100.14/24
#  - name: Ethernet2
#    ipv4:
#      - address: 203.0.113.27/24

返回值

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

描述

after

字典

模块执行后的结果配置。

返回:发生更改时

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

before

字典

模块执行之前的配置。

返回:当 _state_ 为 mergedreplacedoverriddendeletedpurged

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

commands

列表 / 元素=字符串

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

返回:当 _state_ 为 mergedreplacedoverriddendeletedpurged

示例: ["interface Ethernet1", "ip address 198.51.100.14/24", "ipv6 address 2001:db8:feed::1/96"]

gathered

列表 / 元素=字符串

从远程设备收集到的关于网络资源的事实,以结构化数据的形式呈现。

返回:当 _state_ 为 gathered

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

parsed

列表 / 元素=字符串

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

返回:当 _state_ 为 parsed

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

rendered

列表 / 元素=字符串

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

返回:当 _state_ 为 rendered

示例: ["interface Ethernet1", "ip address 198.51.100.14/24", "ipv6 address 2001:db8:feed::1/96"]

作者

  • Nathaniel Case (@Qalthos)