Spec-Zone.ru › Ansible

Модуль arista.eos.eos_l2_interfaces — Модуль ресурса интерфейсов L2

Примечание

Этот модуль является частью коллекции arista.eos (версия 9.0.0).

У вас может быть уже установлена эта коллекция, если вы используете пакет ansible. Она не включена в ansible-core. Чтобы проверить установку, выполните ansible-galaxy collection list.

Чтобы установить её, используйте: ansible-galaxy collection install arista.eos.

Чтобы использовать её в книге задач, укажите: arista.eos.eos_l2_interfaces.

Новое в arista.eos 1.0.0

  • Обзор
  • Параметры
  • Примечания
  • Примеры
  • Возвращаемые значения

Обзор

  • Этот модуль предоставляет декларативное управление интерфейсами второго уровня на устройствах Arista EOS.

Псевдонимы: l2_interfaces

Параметры

Параметр

Комментарии

config

список / элементы=словарь

Словарь параметров интерфейсов второго уровня

access

словарь

Команда switchport mode access для настройки интерфейса как интерфейса доступа второго уровня.

vlan

целое число

Настройка заданного VLAN на порту доступа. Используется как идентификатор VLAN доступа.

mode

строка

Режим настройки интерфейса.

Режим доступа не отображается в фактах интерфейса, поэтому идемпотентность не сохраняется для switchport mode access, и каждый раз результат будет changed=True.

Варианты:

  • "access"
  • "trunk"

name

строка / обязательно

Полное имя интерфейса, например Ethernet1.

trunk

словарь

Команда switchport mode trunk для настройки интерфейса как интерфейса trunk второго уровня.

native_vlan

целое число

Нативный VLAN, который должен быть настроен на порту trunk. Используется как идентификатор VLAN trunk.

trunk_allowed_vlans

список / элементы=строка

Список разрешенных VLAN на заданном порту trunk. Только эти VLAN будут настроены на trunk.

running_config

строка

Этот параметр используется только со состоянием parsed.

Значение этого параметра должно быть результатом выполнения команды show running-config | section ^interface на устройстве EOS.

Состояние parsed считывает конфигурацию из параметра running_config и преобразует её в структурированные данные Ansible в соответствии с argspec модуля ресурса, а затем возвращает значение в ключе parsed в результате.

state

строка

Состояние конфигурации после завершения работы модуля

Варианты:

  • "merged" ← (по умолчанию)
  • "replaced"
  • "overridden"
  • "deleted"
  • "parsed"
  • "rendered"
  • "gathered"

Примечания

Примечание

  • Тестировано на 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
END_OF_DOCUMENT_MARKER

Значения возврата

Общие значения возврата документированы здесь, ниже приведены поля, уникальные для данного модуля:

Ключ

Описание

after

словарь

Результирующая конфигурация после выполнения модуля.

Возвращается: при изменении

Пример: "This output will always be in the same format as the module argspec.\n"

before

словарь

Конфигурация до выполнения модуля.

Возвращается: когда состояние равно merged, replaced, overridden, deleted или purged

Пример: "This output will always be in the same format as the module argspec.\n"

commands

список / элементы=строка

Набор команд, отправленных на удалённое устройство.

Возвращается: когда состояние равно merged, replaced, overridden, deleted или purged

Пример: ["interface Ethernet1", "switchport mode trunk", "switchport access vlan 20"]

gathered

список / элементы=строка

Данные о сетевом ресурсе, собранные с удалённого устройства в виде структурированных данных.

Возвращается: когда состояние равно gathered

Пример: ["This output will always be in the same format as the module argspec.\n"]

parsed

список / элементы=строка

Родная конфигурация устройства, предоставленная в параметре running_config, разобранная в структурированные данные в соответствии со спецификацией аргументов модуля.

Возвращается: когда состояние равно parsed

Пример: ["This output will always be in the same format as the module argspec.\n"]

rendered

список / элементы=строка

Предоставленная конфигурация в задаче, преобразованная в формат, понятный устройству (оффлайн).

Возвращается: когда состояние равно rendered

Пример: ["interface Ethernet1", "switchport mode trunk", "switchport access vlan 20"]

Авторы

  • Nathaniel Case (@Qalthos)

Ссылки на коллекцию

  • Отслеживание проблем
  • Репозиторий (источники)

© 2012–2018 Michael DeHaan
© 2018–2024 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/arista/eos/eos_l2_interfaces_module.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API