cisco.ios.ios_lag_interfaces 模块 – 用于配置 LAG 接口的资源模块。
注意
此模块是 cisco.ios 集合(版本 9.0.3)的一部分。
如果您使用的是 ansible
包,您可能已经安装了此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install cisco.ios
。
要在 playbook 中使用它,请指定:cisco.ios.ios_lag_interfaces
。
cisco.ios 1.0.0 中的新增功能
概要
此模块管理 Cisco IOS 设备上链路聚合组的属性。
参数
参数 |
注释 |
---|---|
链路聚合组配置的列表。 |
|
链路聚合组的接口选项。 |
|
分配一个用于负载均衡的链路标识符。 有关有效值,请参阅供应商文档。 注意,该参数仅在 Cisco IOS XE 平台上支持。 |
|
链路聚合组的接口成员。 |
|
用于链路聚合的接口的以太网通道模式。 “on” 模式必须用引号引起来,如 'on',否则 pyyaml 会在将其传递给 Ansible 之前转换为 True。 选项
|
|
接口的以太网通道 ID。 有关有效的端口值,请参阅供应商文档。 |
|
此选项仅在 state 为 *parsed* 时使用。 此选项的值应为通过执行命令 **show running-config | section ^interface** 从 IOS 设备收到的输出。 state *parsed* 从 |
|
配置应保留的状态 状态 *rendered*、*gathered* 和 *parsed* 不会对设备执行任何更改。 状态 *rendered* 会将 状态 *gathered* 将从设备获取运行配置,并将其转换为结构化数据,格式与资源模块 argspec 相同,并且该值将作为 *gathered* 键在结果中返回。 状态 *parsed* 从 选项
|
注释
注意
在 CML 上针对 Cisco IOSXE 版本 17.3 进行了测试。
此模块与连接
network_cli
配合使用。请参阅 https://docs.ansible.org.cn/ansible/latest/network/user_guide/platform_ios.html
示例
# Using merged
#
# Before state:
# -------------
#
# vios#show running-config | section ^interface
# interface Port-channel10
# interface GigabitEthernet0/1
# shutdown
# interface GigabitEthernet0/2
# shutdown
# interface GigabitEthernet0/3
# shutdown
# interface GigabitEthernet0/4
# shutdown
- name: Merge provided configuration with device configuration
cisco.ios.ios_lag_interfaces:
config:
- name: Port-channel10
members:
- member: GigabitEthernet0/1
mode: auto
- member: GigabitEthernet0/2
mode: auto
- name: Port-channel20
members:
- member: GigabitEthernet0/3
mode: "on"
- name: Port-channel30
members:
- member: GigabitEthernet0/4
mode: active
state: merged
# Task Output:
# ---------------
# commands:
# - interface GigabitEthernet0/1
# - channel-group 10 mode auto
# - interface GigabitEthernet0/2
# - channel-group 10 mode auto
# - interface GigabitEthernet0/3
# - channel-group 20 mode on
# - interface GigabitEthernet0/4
# - channel-group 30 mode active
# After state:
# ------------
#
# vios#show running-config | section ^interface
# interface Port-channel10
# interface Port-channel20
# interface Port-channel30
# interface GigabitEthernet0/1
# shutdown
# channel-group 10 mode auto
# interface GigabitEthernet0/2
# shutdown
# channel-group 10 mode auto
# interface GigabitEthernet0/3
# shutdown
# channel-group 20 mode on
# interface GigabitEthernet0/4
# shutdown
# channel-group 30 mode active
# Using overridden
#
# Before state:
# -------------
#
# vios#show running-config | section ^interface
# interface Port-channel10
# interface Port-channel20
# interface Port-channel30
# interface GigabitEthernet0/1
# shutdown
# channel-group 10 mode auto
# interface GigabitEthernet0/2
# shutdown
# channel-group 10 mode auto
# interface GigabitEthernet0/3
# shutdown
# channel-group 20 mode on
# interface GigabitEthernet0/4
# shutdown
# channel-group 30 mode active
- name: Override device configuration of all interfaces with provided configuration
cisco.ios.ios_lag_interfaces:
config:
- name: Port-channel20
members:
- member: GigabitEthernet0/2
mode: auto
- member: GigabitEthernet0/3
mode: auto
state: overridden
# Task Output:
# ---------------
# commands:
# - interface GigabitEthernet0/1
# - no channel-group 10 mode auto
# - interface GigabitEthernet0/2
# - no channel-group 10 mode auto
# - interface GigabitEthernet0/4
# - no channel-group 30 mode active
# - interface GigabitEthernet0/2
# - channel-group 20 mode auto
# - interface GigabitEthernet0/3
# - channel-group 20 mode auto
# 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
# channel-group 20 mode auto
# interface GigabitEthernet0/3
# shutdown
# channel-group 20 mode auto
# interface GigabitEthernet0/4
# shutdown
# Using replaced
#
# Before state:
# -------------
#
# vios#show running-config | section ^interface
# interface Port-channel10
# interface Port-channel20
# interface Port-channel30
# interface GigabitEthernet0/1
# shutdown
# channel-group 10 mode auto
# interface GigabitEthernet0/2
# shutdown
# channel-group 10 mode auto
# interface GigabitEthernet0/3
# shutdown
# channel-group 20 mode on
# interface GigabitEthernet0/4
# shutdown
# channel-group 30 mode active
- name: Replaces device configuration of listed interfaces with provided configuration
cisco.ios.ios_lag_interfaces:
config:
- name: Port-channel30
members:
- member: GigabitEthernet0/3
mode: auto
state: replaced
# Task Output:
# ---------------
# commands:
# - interface GigabitEthernet0/3
# - channel-group 30 mode auto
# - interface GigabitEthernet0/4
# - no channel-group 30 mode active
# After state:
# ------------
#
# vios#show running-config | section ^interface
# interface Port-channel10
# interface Port-channel20
# interface Port-channel30
# interface GigabitEthernet0/1
# shutdown
# channel-group 10 mode auto
# interface GigabitEthernet0/2
# shutdown
# channel-group 10 mode auto
# interface GigabitEthernet0/3
# shutdown
# channel-group 30 mode auto
# interface GigabitEthernet0/4
# shutdown
# Using Deleted
#
# Before state:
# -------------
#
# vios#show running-config | section ^interface
# interface Port-channel10
# interface Port-channel20
# interface Port-channel30
# interface GigabitEthernet0/1
# shutdown
# channel-group 10 mode auto
# interface GigabitEthernet0/2
# shutdown
# channel-group 10 mode auto
# interface GigabitEthernet0/3
# shutdown
# channel-group 20 mode on
# interface GigabitEthernet0/4
# shutdown
# channel-group 30 mode active
- name: "Delete LAG attributes of given interfaces (Note: This won't delete the interface itself)"
cisco.ios.ios_lag_interfaces:
config:
- name: Port-channel10
- name: Port-channel20
state: deleted
# Task Output:
# ---------------
# commands:
# - interface GigabitEthernet0/1
# - no channel-group 10 mode auto
# - interface GigabitEthernet0/2
# - no channel-group 10 mode auto
# - interface GigabitEthernet0/3
# - no channel-group 20 mode on
# 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
# interface GigabitEthernet0/4
# shutdown
# channel-group 30 mode active
# 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
# interface Port-channel20
# interface Port-channel30
# interface GigabitEthernet0/1
# shutdown
# channel-group 10 mode auto
# interface GigabitEthernet0/2
# shutdown
# channel-group 10 mode auto
# interface GigabitEthernet0/3
# shutdown
# channel-group 20 mode on
# interface GigabitEthernet0/4
# shutdown
# channel-group 30 mode active
- name: "Delete all configured LAG attributes for interfaces (Note: This won't delete the interface itself)"
cisco.ios.ios_lag_interfaces:
state: deleted
# Task Output:
# ---------------
# commands:
# - interface GigabitEthernet0/1
# - no channel-group 10 mode auto
# - interface GigabitEthernet0/2
# - no channel-group 10 mode auto
# - interface GigabitEthernet0/3
# - no channel-group 20 mode on
# - interface GigabitEthernet0/4
# - no channel-group 30 mode active
# 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
# interface GigabitEthernet0/4
# shutdown
# Using Gathered
# Before state:
# -------------
#
# vios#show running-config | section ^interface
# interface Port-channel10
# interface Port-channel20
# interface Port-channel30
# interface GigabitEthernet0/1
# shutdown
# channel-group 10 mode auto
# interface GigabitEthernet0/2
# shutdown
# channel-group 10 mode auto
# interface GigabitEthernet0/3
# shutdown
# channel-group 20 mode on
# interface GigabitEthernet0/4
# shutdown
# channel-group 30 mode active
- name: Gather listed LAG interfaces with provided configurations
cisco.ios.ios_lag_interfaces:
config:
state: gathered
# Module Execution Result:
# ------------------------
#
# "gathered": [
# {
# "members": [
# {
# "member": "GigabitEthernet0/1",
# "mode": "auto"
# },
# {
# "member": "GigabitEthernet0/2",
# "mode": "auto"
# }
# ],
# "name": "Port-channel10"
# },
# {
# "members": [
# {
# "member": "GigabitEthernet0/3",
# "mode": "on"
# }
# ],
# "name": "Port-channel20"
# },
# {
# "members": [
# {
# "member": "GigabitEthernet0/4",
# "mode": "active"
# }
# ],
# "name": "Port-channel30"
# }
# ]
# After state:
# ------------
#
# vios#sh running-config | section ^interface
# interface Port-channel10
# interface Port-channel20
# interface Port-channel30
# interface GigabitEthernet0/1
# shutdown
# channel-group 10 mode auto
# interface GigabitEthernet0/2
# shutdown
# channel-group 10 mode auto
# interface GigabitEthernet0/3
# shutdown
# channel-group 20 mode on
# interface GigabitEthernet0/4
# shutdown
# channel-group 30 mode active
# Using Rendered
- name: Render the commands for provided configuration
cisco.ios.ios_lag_interfaces:
config:
- name: Port-channel11
members:
- member: GigabitEthernet0/1
mode: active
- name: Port-channel22
members:
- member: GigabitEthernet0/2
mode: passive
state: rendered
# Module Execution Result:
# ------------------------
#
# "rendered": [
# "interface GigabitEthernet0/1",
# "channel-group 11 mode active",
# "interface GigabitEthernet0/2",
# "channel-group 22 mode passive",
# ]
# Using Parsed
# File: parsed.cfg
# ----------------
#
# interface GigabitEthernet0/1
# channel-group 11 mode active
# interface GigabitEthernet0/2
# channel-group 22 mode passive
- name: Parse the commands for provided configuration
cisco.ios.ios_lag_interfaces:
running_config: "{{ lookup('file', 'parsed.cfg') }}"
state: parsed
# Module Execution Result:
# ------------------------
#
# "parsed": [
# {
# "members": [
# {
# "member": "GigabitEthernet0/1",
# "mode": "active"
# }
# ],
# "name": "Port-channel11"
# },
# {
# "members": [
# {
# "member": "GigabitEthernet0/2",
# "mode": "passive"
# }
# ],
# "name": "Port-channel22"
# }
# ]
返回值
常见的返回值记录在 此处,以下是此模块特有的字段
键 |
描述 |
---|---|
模块执行后的结果配置。 返回: 当更改时 示例: |
|
模块执行之前的配置。 返回: 当 state 为 示例: |
|
推送到远程设备的一组命令。 返回: 当 state 为 示例: |
|
从远程设备收集的关于网络资源的结构化数据。 返回: 当 state 为 示例: |
|
running_config 选项中提供的设备原生配置,根据模块的 argspec 被解析为结构化数据。 返回值: 当 state 为 示例: |
|
任务中提供的配置以设备原生格式(离线)渲染。 返回值: 当 state 为 示例: |