cisco.ios.ios_lacp_interfaces 模块 – 配置 LACP 接口的资源模块。

注意

此模块是 cisco.ios 集合 (版本 9.0.3) 的一部分。

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

要安装它,请使用: ansible-galaxy collection install cisco.ios

要在 playbook 中使用它,请指定: cisco.ios.ios_lacp_interfaces

cisco.ios 1.0.0 新增功能

概要

  • 此模块提供对 Cisco IOS 网络设备 lacp_interfaces 上 LACP 的声明式管理。

参数

参数

注释

config

列表 / 元素=字典

LACP lacp_interfaces 选项的字典

fast_switchover

布尔值

此端口通道上支持的 LACP 快速切换。

选项

  • false

  • true

max_bundle

整数

此端口通道中捆绑的最大端口数。

请参考供应商文档以获取有效的端口值。

name

字符串 / 必需

配置 LACP 的接口名称。

port_priority

整数

此接口上的 LACP 优先级。

请参考供应商文档以获取有效的端口值。

running_config

字符串

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

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

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

state

字符串

配置应保留的状态

状态 *rendered*、*gathered* 和 *parsed* 不会对设备进行任何更改。

状态 *rendered* 将 config 选项中的配置转换为特定于平台的 CLI 命令,这些命令将在结果中的 *rendered* 键中返回。对于状态 *rendered*,不需要与远程主机的活动连接。

状态 *gathered* 将从设备获取运行配置,并根据资源模块 argspec 将其转换为结构化数据,并在结果中的 *gathered* 键中返回该值。

状态 *parsed* 从 running_config 选项读取配置,并根据资源模块参数将其转换为 JSON 格式,并在结果中的 *parsed* 键中返回该值。running_config 选项的值应与在设备上执行的命令 *show running-config | include ip route|ipv6 route* 的输出格式相同。对于状态 *parsed*,不需要与远程主机的活动连接。

选项

  • "merged" ← (默认)

  • "replaced"

  • "overridden"

  • "deleted"

  • "rendered"

  • "gathered"

  • "parsed"

备注

注意

示例

# Using merged
#
# Before state:
# -------------
#
# vios#show running-config | section ^interface
# interface Port-channel10
# interface Port-channel20
# interface Port-channel30
# interface GigabitEthernet0/1
#  shutdown
# interface GigabitEthernet0/2
#  shutdown
# interface GigabitEthernet0/3
#  shutdown

- name: Merge provided configuration with device configuration
  cisco.ios.ios_lacp_interfaces:
    config:
      - name: GigabitEthernet0/1
        port_priority: 10
      - name: GigabitEthernet0/2
        port_priority: 20
      - name: GigabitEthernet0/3
        port_priority: 30
      - name: Port-channel10
        fast_switchover: true
        max_bundle: 5
    state: merged

# After state:
# ------------
#
# vios#show running-config | section ^interface
# interface Port-channel10
#  lacp fast-switchover
#  lacp max-bundle 5
# interface Port-channel20
# interface Port-channel30
# interface GigabitEthernet0/1
#  shutdown
#  lacp port-priority 10
# interface GigabitEthernet0/2
#  shutdown
#  lacp port-priority 20
# interface GigabitEthernet0/3
#  shutdown
#  lacp port-priority 30

# Using overridden
#
# Before state:
# -------------
#
# vios#show running-config | section ^interface
# interface Port-channel10
#  lacp fast-switchover
# interface Port-channel20
# interface Port-channel30
# interface GigabitEthernet0/1
#  shutdown
#  lacp port-priority 10
# interface GigabitEthernet0/2
#  shutdown
#  lacp port-priority 20
# interface GigabitEthernet0/3
#  shutdown
#  lacp port-priority 30

- name: Override device configuration of all lacp_interfaces with provided configuration
  cisco.ios.ios_lacp_interfaces:
    config:
      - name: GigabitEthernet0/1
        port_priority: 20
      - name: Port-channel10
        max_bundle: 2
    state: overridden

# After state:
# ------------
#
# vios#show running-config | section ^interface
# interface Port-channel10
#  lacp max-bundle 2
# interface Port-channel20
# interface Port-channel30
# interface GigabitEthernet0/1
#  shutdown
#  lacp port-priority 20
# interface GigabitEthernet0/2
#  shutdown
# interface GigabitEthernet0/3
#  shutdown

# Using replaced
#
# Before state:
# -------------
#
# vios#show running-config | section ^interface
# interface Port-channel10
#  lacp max-bundle 5
# interface Port-channel20
# interface Port-channel30
# interface GigabitEthernet0/1
#  shutdown
#  lacp port-priority 10
# interface GigabitEthernet0/2
#  shutdown
#  lacp port-priority 20
# interface GigabitEthernet0/3
#  shutdown
#  lacp port-priority 30

- name: Replaces device configuration of listed lacp_interfaces with provided configuration
  cisco.ios.ios_lacp_interfaces:
    config:
      - name: GigabitEthernet0/3
        port_priority: 40
      - name: Port-channel10
        fast_switchover: true
        max_bundle: 2
    state: replaced

# After state:
# ------------
#
# vios#show running-config | section ^interface
# interface Port-channel10
#  lacp fast-switchover
#  lacp max-bundle 2
# interface Port-channel20
# interface Port-channel30
# interface GigabitEthernet0/1
#  shutdown
#  lacp port-priority 10
# interface GigabitEthernet0/2
#  shutdown
#  lacp port-priority 20
# interface GigabitEthernet0/3
#  shutdown
#  lacp port-priority 40

# Using Deleted
#
# Before state:
# -------------
#
# vios#show running-config | section ^interface
# interface Port-channel10
#  flowcontrol receive on
# interface Port-channel20
# interface Port-channel30
# interface GigabitEthernet0/1
#  shutdown
#  lacp port-priority 10
# interface GigabitEthernet0/2
#  shutdown
#  lacp port-priority 20
# interface GigabitEthernet0/3
#  shutdown
#  lacp port-priority 30

- name: "Delete LACP attributes of given interfaces (Note: This won't delete the interface itself)"
  cisco.ios.ios_lacp_interfaces:
    config:
      - name: GigabitEthernet0/1
    state: deleted

# After state:
# -------------
#
# vios#show running-config | section ^interface
# interface Port-channel10
# interface Port-channel20
# interface Port-channel30
# interface GigabitEthernet0/1
#  shutdown
# interface GigabitEthernet0/2
#  shutdown
#  lacp port-priority 20
# interface GigabitEthernet0/3
#  shutdown
#  lacp port-priority 30

# Using Deleted without any config passed
# "(NOTE: This will delete all of configured LLDP module attributes)"
#
# Before state:
# -------------
#
# vios#show running-config | section ^interface
# interface Port-channel10
#  lacp fast-switchover
# interface Port-channel20
#  lacp max-bundle 2
# interface Port-channel30
# interface GigabitEthernet0/1
#  shutdown
#  lacp port-priority 10
# interface GigabitEthernet0/2
#  shutdown
#  lacp port-priority 20
# interface GigabitEthernet0/3
#  shutdown
#  lacp port-priority 30

- name: "Delete LACP attributes for all configured interfaces (Note: This won't delete the interface itself)"
  cisco.ios.ios_lacp_interfaces:
    state: deleted

# After state:
# -------------
#
# vios#show running-config | section ^interface
# interface Port-channel10
# interface Port-channel20
# interface Port-channel30
# interface GigabitEthernet0/1
#  shutdown
# interface GigabitEthernet0/2
#  shutdown
# interface GigabitEthernet0/3
#  shutdown

# Using Gathered

# Before state:
# -------------
#
# vios#sh running-config | section ^interface
# interface Port-channel10
#  lacp fast-switchover
#  lacp max-bundle 2
# interface Port-channel40
#  lacp max-bundle 5
# interface GigabitEthernet0/0
# interface GigabitEthernet0/1
#  lacp port-priority 30
# interface GigabitEthernet0/2
#  lacp port-priority 20

- name: Gather listed LACP interfaces with provided configurations
  cisco.ios.ios_lacp_interfaces:
    config:
    state: gathered

# Module Execution Result:
# ------------------------
#
# "gathered": [
#         {
#             "fast_switchover": true,
#             "max_bundle": 2,
#             "name": "Port-channel10"
#         },
#         {
#             "max_bundle": 5,
#             "name": "Port-channel40"
#         },
#         {
#             "name": "GigabitEthernet0/0"
#         },
#         {
#             "name": "GigabitEthernet0/1",
#             "port_priority": 30
#         },
#         {
#             "name": "GigabitEthernet0/2",
#             "port_priority": 20
#         }
#     ]

# After state:
# ------------
#
# vios#sh running-config | section ^interface
# interface Port-channel10
#  lacp fast-switchover
#  lacp max-bundle 2
# interface Port-channel40
#  lacp max-bundle 5
# interface GigabitEthernet0/0
# interface GigabitEthernet0/1
#  lacp port-priority 30
# interface GigabitEthernet0/2
#  lacp port-priority 20

# Using Rendered

- name: Render the commands for provided  configuration
  cisco.ios.ios_lacp_interfaces:
    config:
      - name: GigabitEthernet0/1
        port_priority: 10
      - name: GigabitEthernet0/2
        port_priority: 20
      - name: Port-channel10
        fast_switchover: true
        max_bundle: 2
    state: rendered

# Module Execution Result:
# ------------------------
#
# "rendered": [
#         "interface GigabitEthernet0/1",
#         "lacp port-priority 10",
#         "interface GigabitEthernet0/2",
#         "lacp port-priority 20",
#         "interface Port-channel10",
#         "lacp max-bundle 2",
#         "lacp fast-switchover"
#     ]

# Using Parsed

# File: parsed.cfg
# ----------------
#
# interface GigabitEthernet0/1
# lacp port-priority 10
# interface GigabitEthernet0/2
# lacp port-priority 20
# interface Port-channel10
# lacp max-bundle 2 fast-switchover

- name: Parse the commands for provided configuration
  cisco.ios.ios_lacp_interfaces:
    running_config: "{{ lookup('file', 'parsed.cfg') }}"
    state: parsed

# Module Execution Result:
# ------------------------
#
# "parsed": [
#         {
#             "name": "GigabitEthernet0/1",
#             "port_priority": 10
#         },
#         {
#             "name": "GigabitEthernet0/2",
#             "port_priority": 20
#         },
#         {
#             "fast_switchover": true,
#             "max_bundle": 2,
#             "name": "Port-channel10"
#         }
#     ]

返回值

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

描述

after

列表 / 元素=字符串

模块完成后的结构化数据配置。

返回:发生更改时

示例: ["The configuration returned will always be in the same format\n of the parameters above.\n"]

before

列表 / 元素=字符串

模块调用之前的结构化数据配置。

返回:始终返回

示例: ["The configuration returned will always be in the same format\n of the parameters above.\n"]

commands

列表 / 元素=字符串

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

返回:始终返回

示例: ["interface GigabitEthernet 0/1", "lacp port-priority 30"]

作者

  • Sumit Jaiswal (@justjais)