cisco.nxos.nxos_fc_interfaces 模块 – Fc 接口资源模块

注意

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

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

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

要在 playbook 中使用它,请指定:cisco.nxos.nxos_fc_interfaces

cisco.nxos 5.2.0 中新增

概要

  • 此模块管理 NX-OS fc 接口的接口属性。

参数

参数

注释

config

列表 / 元素=字典

接口选项的字典

analytics

字符串

fc 接口上的分析类型

选择

  • "fc-scsi"

  • "fc-nvme"

  • "fc-all"

description

字符串

接口描述。

enabled

布尔值

接口的管理状态。将值设置为 true 以管理方式启用接口,或设置为 true 以禁用它

选择

  • false

  • true

mode

字符串

fc 接口的端口模式

选择

  • "auto"

  • "E"

  • "F"

  • "Fx"

  • "NP"

  • "SD"

name

字符串 / 必需

接口的全名,例如 fc1/1、fc18/48

speed

字符串

接口链路速度。

选择

  • "auto"

  • "1000"

  • "2000"

  • "4000"

  • "8000"

  • "10000"

  • "16000"

  • "32000"

  • "64000"

  • "auto max 2000"

  • "auto max 4000"

  • "auto max 8000"

  • "auto max 16000"

  • "auto max 32000"

  • "auto max 64000"

trunk_mode

字符串

fc 接口的链路模式

选择

  • "auto"

  • "on"

  • "off"

running_config

字符串

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

此选项的值应是通过执行命令 show running-config interface 从 NX-OS 设备接收的输出

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

state

字符串

模块完成后配置的状态

选择

  • "merged" ← (默认)

  • "replaced"

  • "overridden"

  • "deleted"

  • "gathered"

  • "rendered"

  • "parsed"

备注

注意

  • 在 Cisco MDS 交换机上针对 NXOS 9.3(2) 进行了测试

示例

# Using merged

# Before state:
# -------------
#
# switch# show running-config interface all
# interface fc18/10
#     analytics type fc-nvme
#     switchport speed auto max 16000
#     switchport mode auto
#     switchport description $
#     switchport trunk mode on
#     shutdown

- name: Merge provided configuration with device configuration
  cisco.nxos.nxos_fc_interfaces:
    config:
      - name: fc18/10
        analytics: fc-scsi
    state: merged

# Task Output
# -----------
#
# before:
# - name: fc18/10
#   speed: auto max 16000
#   mode: auto
#   trunk_mode: on
#   enabled: true
#   description: $
#   analytics: fc-nvme
# commands:
# - interface fc18/10
# - analytics type fc-scsi
# after:
# - name: fc18/10
#   speed: auto max 16000
#   mode: auto
#   trunk_mode: on
#   enabled: true
#   description: $
#   analytics: fc-all

# After state:
# ------------
#
# switch# show running-config interface all
# interface fc18/10
#     analytics type fc-scsi
#     analytics type fc-nvme
#     switchport speed auto max 16000
#     switchport mode auto
#     switchport description $
#     switchport trunk mode on
#     shutdown

# Using replaced

# Before state:
# -------------
#
# switch# show running-config interface all
# interface fc18/12
#     analytics type fc-scsi
#     analytics type fc-nvme
#     switchport speed auto max 64000
#     switchport mode auto
#     switchport description 1
#     switchport trunk mode on
#     no shutdown

- name: Replaces device configuration of listed interfaces with provided configuration
  cisco.nxos.nxos_fc_interfaces:
    config:
      - name: fc18/12
        speed: auto max 64000
        mode: auto
        trunk_mode: "on"
        enabled: true
        description: 1
        analytics: fc-scsi
    state: replaced

# Task Output
# -----------
#
# before:
# - name: fc18/12
#   speed: auto max 64000
#   mode: auto
#   trunk_mode: on
#   enabled: true
#   description: 1
#   analytics: fc-all
# commands:
# - interface fc18/12
# - no analytics type fc-all
# - analytics type fc-scsi
# after:
# - name: fc18/12
#   speed: auto max 64000
#   mode: auto
#   trunk_mode: on
#   enabled: true
#   description: 1
#   analytics: fc-scsi

# After state:
# ------------
#
# switch# show running-config interface all
# interface fc18/12
#     analytics type fc-scsi
#     switchport speed auto max 64000
#     switchport mode auto
#     switchport description 1
#     switchport trunk mode on
#     no shutdown


# Using deleted

# Before state:
# -------------
#
# switch# show running-config interface all
# interface fc1/2
#     switchport speed 1000
#     switchport mode E
#     no switchport description
#     switchport trunk mode off
#     no shutdown

- name: Delete or return interface parameters to default settings
  cisco.nxos.nxos_fc_interfaces:
    config:
      - name: fc1/2
    state: deleted

# Task Output
# -----------
#
# before:
# - name: fc1/2
#   speed: 1000
#   mode: E
#   trunk_mode: off
#   enabled: true
# commands:
# - interface fc1/2
# - no switchport speed 1000
# - no switchport mode E
# - switchport trunk mode on
# - shutdown
# after:
# - name: fc1/2
#   speed: auto
#   mode: auto
#   trunk_mode: on
#   enabled: true

# After state:
# ------------
#
# switch# show running-config interface all
# interface fc1/2
#     switchport speed auto
#     switchport mode auto
#     no switchport description
#     switchport trunk mode on
#     shutdown

# Using overridden

# Before state:
# -------------
#
# switch# show running-config interface all
# interface fc18/12
#     analytics type fc-scsi
#     analytics type fc-nvme
#     switchport speed auto max 64000
#     switchport mode auto
#     switchport description 1
#     switchport trunk mode on
#     no shutdown
# interface fc18/13
#     analytics type fc-scsi
#     analytics type fc-nvme
#     switchport speed auto max 64000
#     switchport mode auto
#     switchport description 1
#     switchport trunk mode on
#     no shutdown

- name: Replaces device configuration of listed interfaces with provided configuration
  cisco.nxos.nxos_fc_interfaces:
    config:
      - name: fc18/12
        speed: auto max 64000
        mode: auto
        trunk_mode: "on"
        enabled: true
        description: 1
        analytics: fc-scsi
    state: overridden

# Task Output
# -----------
#
# before:
# - name: fc18/12
#   speed: auto max 64000
#   mode: auto
#   trunk_mode: on
#   enabled: true
#   description: 1
#   analytics: fc-all
# - name: fc18/13
#   speed: auto max 64000
#   mode: auto
#   trunk_mode: on
#   enabled: true
#   description: 1
#   analytics: fc-all
# commands:
# - interface fc18/12
#   no analytics type fc-all
#   analytics type fc-scsi
# - interface fc18/13
#   no switchport description
#   no switchport speed auto max 64000
#   no switchport mode auto
#   switchport trunk mode on
#   shutdown
# after:
# - name: fc18/12
#   speed: auto max 64000
#   mode: auto
#   trunk_mode: on
#   enabled: true
#   description: 1
#   analytics: fc-scsi
# - name: fc18/13
#   speed: auto max 64000
#   mode: auto
#   trunk_mode: on
#   enabled: true

# After state:
# ------------
#
# switch# show running-config interface all
# interface fc18/12
#     analytics type fc-scsi
#     switchport speed auto max 64000
#     switchport mode auto
#     switchport description 1
#     switchport trunk mode on
#     no shutdown
# interface fc18/13
#     switchport mode auto
#     switchport trunk mode on
#     shutdown

# Using rendered

- name: Use rendered state to convert task input to device specific commands
  cisco.nxos.nxos_fc_interfaces:
    config:
      - name: fc1/1
        speed: auto
        mode: auto
        trunk_mode: "on"
        enabled: true
        description: This is a sample line
      - name: fc1/2
        speed: 1000
        mode: E
        trunk_mode: "off"
        enabled: true
        state: rendered

# Task Output
# -----------
#
# rendered:
# interface fc1/1
#     switchport speed auto
#     switchport mode auto
#     switchport description This is a sample line
#     switchport trunk mode on
#     no shutdown
#
# interface fc1/2
#     switchport speed 1000
#     switchport mode E
#     no switchport description
#     switchport trunk mode off
#     no shutdown

# Using parsed

# parsed.cfg
# ------------
#
# interface fc1/1
#     switchport speed auto
#     switchport mode auto
#     switchport description This is a sample line
#     switchport trunk mode on
#     no shutdown
#
# interface fc1/2
#     switchport speed 1000
#     switchport mode E
#     no switchport description
#     switchport trunk mode off
#     no shutdown

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

# Task output
# -----------
#
#  parsed:
# - name: fc1/1
#   speed: auto
#   mode: auto
#   trunk_mode: on
#   enabled: true
#   description: This is a sample line
# - name: fc1/2
#   speed: 1000
#   mode: E
#   trunk_mode: off
#   enabled: true

# Using gathered

# Before state:
# -------------
#
# switch# show running-config | section interface
# interface fc1/1
#     switchport speed auto
#     switchport mode auto
#     switchport description This is a sample line
#     switchport trunk mode on
#     no shutdown
#
# interface fc1/2
#     switchport speed 1000
#     switchport mode E
#     no switchport description
#     switchport trunk mode off
#     no shutdown
#
- name: Gather interfaces facts from the device using nxos_fc_interfaces
  cisco.nxos.nxos_fc_interfaces:
    state: gathered
#
# Task output
# -----------
#
# - name: fc1/1
#   speed: auto
#   mode: auto
#   trunk_mode: on
#   enabled: true
#   description: This is a sample line
# - name: fc1/2
#   speed: 1000
#   mode: E
#   trunk_mode: off
#   enabled: true

返回值

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

描述

after

字典

模块执行后的结果配置。

返回: 当 changed

示例: "此输出将始终与模块 argspec 的格式相同。\n"

before

字典

模块执行之前的配置。

返回:statemergedreplacedoverriddendeletedpurged

示例: "此输出将始终与模块 argspec 的格式相同。\n"

commands

列表 / 元素=字符串

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

返回:statemergedreplacedoverriddendeletedpurged

示例: ["interface fc1/1", "description sample description", "shutdown"]

gathered

列表 / 元素=字符串

从远程设备收集的关于网络资源的事实,作为结构化数据。

返回:stategathered

示例: ["此 输出 将始终 与模块 argspec 格式相同。\n"]

已解析

列表 / 元素=字符串

根据模块 argspec,将 running_config 选项中提供的设备原生配置解析为结构化数据。

返回:stateparsed

示例: ["此 输出 将始终 与模块 argspec 格式相同。\n"]

已渲染

列表 / 元素=字符串

任务中提供的配置以设备原生格式(离线)渲染。

返回:staterendered

示例: ["interface fc1/1", "description sample description", "shutdown"]

作者

  • Suhas Bharadwaj (@srbharadwaj)