cisco.nxos.nxos_lag_interfaces 模块 – LAG 接口资源模块

注意

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

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

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

要在剧本中使用它,请指定:cisco.nxos.nxos_lag_interfaces

cisco.nxos 1.0.0 中的新功能

概要

  • 此模块管理 NX-OS 接口的链路聚合组的属性。

参数

参数

注释

config

list / elements=dictionary

链路聚合组配置的列表。

members

list / elements=dictionary

属于该组的接口列表。

force

boolean

如果为 true,则强制链路聚合组成员与成员参数中声明的内容匹配。这可用于删除成员。

选择

  • false

  • true

member

string

接口名称。

mode

string

链路聚合组 (LAG)。

选择

  • "active"

  • "on"

  • "passive"

name

string / required

链路聚合组 (LAG) 的名称。

running_config

string

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

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

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

state

string

模块完成后配置的状态。

选择

  • "merged" ← (默认)

  • "replaced"

  • "overridden"

  • "deleted"

  • "gathered"

  • "rendered"

  • "parsed"

备注

注意

  • 在 VIRL 上针对 NXOS 7.3.(0)D1(1) 进行了测试。

  • 不支持 Cisco MDS

  • 此模块与连接 network_cli 一起使用。

示例

# Using merged

# Before state:
# -------------
#
# interface Ethernet1/4

- name: Merge provided configuration with device configuration.
  cisco.nxos.nxos_lag_interfaces:
    config:
      - name: port-channel99
        members:
          - member: Ethernet1/4
    state: merged

# After state:
# ------------
#
# interface Ethernet1/4
#   channel-group 99


# Using replaced

# Before state:
# -------------
#
# interface Ethernet1/4
#   channel-group 99 mode active

- name: Replace device configuration of specified LAG attributes of given interfaces
    with provided configuration.
  cisco.nxos.nxos_lag_interfaces:
    config:
      - name: port-channel10
        members:
          - member: Ethernet1/4
    state: replaced

# After state:
# ------------
#
# interface Ethernet1/4
#   channel-group 10


# Using overridden

# Before state:
# -------------
#
# interface Ethernet1/4
#   channel-group 10
# interface Ethernet1/2
#   channel-group 99 mode passive

- name: Override device configuration of all LAG attributes of given interfaces on
    device with provided configuration.
  cisco.nxos.nxos_lag_interfaces:
    config:
      - name: port-channel20
        members:
          - member: Ethernet1/6
            force: true
    state: overridden

# After state:
# ------------
# interface Ethernet1/2
# interface Ethernet1/4
# interface Ethernet1/6
#   channel-group 20 force


# Using deleted

# Before state:
# -------------
#
# interface Ethernet1/4
#   channel-group 99 mode active

- name: Delete LAG attributes of given interface (This won't delete the port-channel
    itself).
  cisco.nxos.nxos_lag_interfaces:
    config:
      - port-channel: port-channel99
    state: deleted

- name: Delete LAG attributes of all the interfaces
  cisco.nxos.nxos_lag_interfaces:
    state: deleted

# After state:
# ------------
#
# interface Ethernet1/4
#   no channel-group 99

# Using rendered

- name: Use rendered state to convert task input to device specific commands
  cisco.nxos.nxos_lag_interfaces:
    config:
      - name: port-channel10
        members:
          - member: Ethernet1/800
            mode: active
          - member: Ethernet1/801
      - name: port-channel11
        members:
          - member: Ethernet1/802
            mode: passive
    state: rendered

# Task Output (redacted)
# -----------------------

# rendered:
#  - "interface Ethernet1/800"
#  - "channel-group 10 mode active"
#  - "interface Ethernet1/801"
#  - "channel-group 10"
#  - "interface Ethernet1/802"
#  - "channel-group 11 mode passive"

# Using parsed

# parsed.cfg
# ------------

# interface port-channel10
# interface port-channel11
# interface port-channel12
# interface Ethernet1/800
#   channel-group 10 mode active
# interface Ethernet1/801
#   channel-group 10 mode active
# interface Ethernet1/802
#   channel-group 11 mode passive
# interface Ethernet1/803
#   channel-group 11 mode passive

- name: Use parsed state to convert externally supplied config to structured format
  cisco.nxos.nxos_lag_interfaces:
    running_config: "{{ lookup('file', 'parsed.cfg') }}"
    state: parsed

# Task output (redacted)
# -----------------------

# parsed:
#  - members:
#      - member: Ethernet1/800
#        mode: active
#      - member: Ethernet1/801
#        mode: active
#    name: port-channel10
#
#  - members:
#      - member: Ethernet1/802
#        mode: passive
#      - member: Ethernet1/803
#        mode: passive
#    name: port-channel11
#
#  - name: port-channel12

# Using gathered

# Existing device config state
# -------------------------------
# interface port-channel10
# interface port-channel11
# interface Ethernet1/1
#   channel-group 10 mode active
# interface Ethernet1/2
#   channel-group 11 mode passive
#

- name: Gather lag_interfaces facts from the device using nxos_lag_interfaces
  cisco.nxos.nxos_lag_interfaces:
    state: gathered

# Task output (redacted)
# -----------------------
# gathered:
#  - name: port-channel10
#    members:
#      - member: Ethernet1/1
#        mode: active
#  - name: port-channel11
#    members:
#      - member: Ethernet1/2
#        mode: passive

返回值

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

描述

after

list / elements=string

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

返回:当发生更改时

示例: ["返回的配置将始终与上述参数的格式相同\n"]

before

list / elements=string

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

返回:始终

示例: ["返回的配置将始终与上述参数的格式相同\n"]

commands

list / elements=string

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

返回:始终

示例: ["interface Ethernet1/800", "channel-group 10 mode active", "interface Ethernet1/801", "channel-group 10", "interface Ethernet1/802", "channel-group 11 mode passive"]

作者

  • Trishna Guha (@trishnaguha)

  • Nilashish Chakraborty (@NilashishC)