Модуль arista.eos.eos_l2_interfaces — модуль ресурса интерфейсов L2
Примечание
Этот модуль входит в коллекцию arista.eos (версия 12.1.2).
Возможно, эта коллекция уже установлена, если вы используете пакет ansible. Она не входит в ansible-core. Чтобы проверить, установлена ли она, выполните ansible-galaxy collection list.
Для установки используйте: ansible-galaxy collection install arista.eos.
Чтобы использовать коллекцию в плейбуке, укажите: arista.eos.eos_l2_interfaces.
Новое в arista.eos 1.0.0
Краткое описание
- Этот модуль обеспечивает декларативное управление интерфейсами уровня 2 на устройствах Arista EOS.
Примечание
Для этого модуля имеется соответствующий плагин действий.
Псевдонимы: l2_interfaces
Параметры
Параметр | Комментарии |
|---|---|
config list / elements=dictionary | Словарь параметров интерфейса уровня 2 |
|
access dictionary |
Команда Switchport mode access для настройки интерфейса в качестве порта доступа уровня 2. |
|
vlan integer |
Настройка указанной VLAN для порта доступа. Используется в качестве идентификатора VLAN доступа. |
|
mode string |
Режим, в котором необходимо настроить интерфейс. Режим доступа не отображается в фактах об интерфейсе, поэтому идемпотентность для switchport mode access не обеспечивается и при каждом запуске результат будет содержать changed=True. Варианты:
|
|
name string / обязательный |
Полное имя интерфейса, например Ethernet1. |
|
trunk dictionary |
Команда Switchport mode trunk для настройки интерфейса в качестве транкового порта уровня 2. |
|
native_vlan integer |
Native VLAN, настраиваемая для транкового порта. Используется в качестве идентификатора native VLAN транка. |
|
trunk_allowed_vlans list / elements=string |
Список VLAN, разрешённых на указанном транковом порту. На транке будут настроены только эти VLAN. |
running_config string | Этот параметр используется только при значении состояния parsed. Значением этого параметра должен быть вывод устройства EOS, полученный при выполнении команды show running-config | section ^interface. Состояние parsed считывает конфигурацию из параметра |
state string | Состояние конфигурации после выполнения модуля Варианты:
|
Примечания
Примечание
- Протестировано на Arista EOS 4.24.6F
- Этот модуль работает с подключением
network_cli. См. https://docs.ansible.com/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
Возвращаемые значения
Общие возвращаемые значения описаны здесь; ниже перечислены поля, уникальные для этого модуля:
Ключ | Описание |
|---|---|
after dictionary | Итоговая конфигурация после выполнения модуля. Возвращается: при наличии изменений Пример: |
before dictionary | Конфигурация до выполнения модуля. Возвращается: когда state имеет значение Пример: |
commands list / elements=string | Набор команд, отправленных на удалённое устройство. Возвращается: когда state имеет значение Пример: |
gathered list / elements=string | Сведения о сетевом ресурсе, собранные с удалённого устройства в виде структурированных данных. Возвращается: когда state имеет значение Пример: |
parsed list / elements=string | Собственная конфигурация устройства, переданная в параметре running_config и разобранная в структурированные данные в соответствии со спецификацией аргументов модуля. Возвращается: когда state имеет значение Пример: |
rendered list / elements=string | Конфигурация, указанная в задаче, преобразованная в собственный формат устройства (без подключения к устройству). Возвращается: когда state имеет значение Пример: |
Ссылки на коллекцию
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/projects/ansible/latest/collections/arista/eos/eos_l2_interfaces_module.html