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 设备上的三层接口的声明式管理。
参数
参数 |
注释 |
---|---|
三层接口选项的字典 |
|
要在 _name_ 选项中提到的三层接口上设置的 IPv4 地址列表。 |
|
要设置的 IPv4 地址,格式为 |
|
此地址是否为辅助地址。 选项
|
|
此地址是否为虚拟地址。 选项
|
|
要在 _name_ 选项中提到的三层接口上设置的 IPv6 地址列表。 |
|
要设置的 IPv6 地址,地址格式为 |
|
接口的全名,即 Ethernet1。 |
|
此选项仅与 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 在使用此模块 (eos_l3_interfaces) 应用 L3 配置之前,应使用 ‘eos_l2_interfaces/eos_interfaces’ 来准备接口。
示例
# 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
返回值
常见的返回值已在此处记录 此处,以下是此模块特有的字段
键 |
描述 |
---|---|
模块执行后的结果配置。 返回:发生更改时 示例: |
|
模块执行之前的配置。 返回:当 _state_ 为 示例: |
|
推送到远程设备的命令集。 返回:当 _state_ 为 示例: |
|
从远程设备收集到的关于网络资源的事实,以结构化数据的形式呈现。 返回:当 _state_ 为 示例: |
|
根据模块 argspec 将 _running_config_ 选项中提供的设备原生配置解析为结构化数据。 返回:当 _state_ 为 示例: |
|
以设备原生格式(离线)呈现的任务中提供的配置。 返回:当 _state_ 为 示例: |