cisco.dnac.device_credential_intent 模块 – 用于全局设备凭证和将凭证分配给站点的资源模块。

注意

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

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

要安装它,请使用:ansible-galaxy collection install cisco.dnac。您需要其他要求才能使用此模块,请参阅 要求 获取详细信息。

要在 playbook 中使用它,请指定:cisco.dnac.device_credential_intent

cisco.dnac 6.7.0 中的新增功能

概要

  • 管理全局设备凭证和将凭证分配给站点的操作。

  • 创建全局设备凭证的 API。

  • 更新全局设备凭证的 API。

  • 删除全局设备凭证的 API。

  • 将设备凭证分配给站点的 API。

要求

执行此模块的主机需要以下要求。

  • dnacentersdk >= 2.7.2

  • python >= 3.9

参数

参数

注释

config

列表 / 元素=字典 / 必需

全局设备凭证和站点名称的详细信息列表。

assign_credentials_to_site

字典

将设备凭证分配给站点。

cli_credential

字典

CLI 凭证。

description

字符串

CLI 凭证描述。

id

字符串

CLI 凭证 ID。使用(描述、用户名)或 ID。

username

字符串

CLI 凭证用户名。

https_read

字典

HTTP(S) 读取凭证

description

字符串

HTTP(S) 读取凭证描述。

id

字符串

HTTP(S) 读取凭证 ID。使用(描述、用户名)或 ID。

username

字符串

HTTP(S) 读取凭证用户名。

https_write

字典

HTTP(S) 写入凭证

description

字符串

HTTP(S) 写入凭证描述。

id

字符串

HTTP(S) 写入凭证 ID。使用(描述、用户名)或 ID。

username

字符串

HTTP(S) 写入凭证用户名。

site_name

列表 / 元素=字符串

要分配凭证的站点名称。

snmp_v2c_read

字典

SNMPv2c 读取凭证

description

字符串

SNMPv2c 读取凭证描述。

id

字符串

SNMPv2c 读取凭证 ID。使用描述或 ID。

snmp_v2c_write

字典

SNMPv2c 写入凭证

description

字符串

SNMPv2c 写入凭证描述。

id

字符串

SNMPv2c 写入凭证 ID。使用描述或 ID。

snmp_v3

字典

snmp_v3 凭证

description

字符串

snmp_v3 凭证描述。

id

字符串

snmp_v3 凭证 ID。使用描述或 ID。

global_credential_details

字典

管理全局设备凭证

cli_credential

列表 / 元素=字典

全局凭证 V2 的 cliCredential。

description

字符串

描述。创建凭证所必需的。

enable_password

字符串

cli_credential 凭证启用密码。

密码不能包含空格或尖括号 (< >)

id

字符串

凭证 ID。使用此 ID 更新设备凭证。

old_description

字符串

旧描述。使用此项更新描述/用户名。

old_username

字符串

旧用户名。使用此项更新描述/用户名。

password

字符串

cli_credential 凭证密码。

创建/更新凭证所必需的。

密码不能包含空格或尖括号 (< >)。

username

字符串

cli_credential 凭证用户名。

用户名不能包含空格或尖括号 (< >)。

https_read

列表 / 元素=字典

全局凭证 V2 的 httpsRead。

id

字符串

凭证 ID。使用此 ID 更新设备凭证。

name

字符串

名称。创建凭证所必需的。

old_description

字符串

旧描述。使用此项更新描述/用户名。

old_username

字符串

旧用户名。使用此项更新描述/用户名。

password

字符串

https_read 凭证密码。

创建/更新凭证所必需的。

密码不能包含空格或尖括号 (< >)。

port

整数

端口。默认端口为 443。

username

字符串

https_read 凭证用户名。

用户名不能包含空格或尖括号 (< >)。

https_write

列表 / 元素=字典

全局凭证 V2 的 httpsWrite。

id

字符串

凭证 ID。使用此 ID 更新设备凭证。

name

字符串

名称。创建凭证所必需的。

old_description

字符串

旧描述。使用此项更新描述/用户名。

old_username

字符串

旧用户名。使用此项更新描述/用户名。

password

字符串

https_write 凭证密码。

创建/更新凭证所必需的。

密码不能包含空格或尖括号 (< >)。

port

整数

端口。默认端口为 443。

username

字符串

https_write 凭证用户名。

用户名不能包含空格或尖括号 (< >)。

snmp_v2c_read

列表 / 元素=字典

全局凭证 V2 的 snmpV2cRead。

description

字符串

描述。创建凭证所必需的。

id

字符串

凭证 ID。使用此 ID 更新设备凭证。

old_description

字符串

旧描述。使用此项更新描述。

read_community

字符串

snmp_v2c_read 读取团体。

密码不能包含空格或尖括号 (< >)。

snmp_v2c_write

列表 / 元素=字典

全局凭证 V2 的 snmpV2cWrite。

description

字符串

描述。创建凭证所必需的。

id

字符串

凭证 ID。使用此 ID 更新设备凭证。

old_description

字符串

旧描述。使用此项更新描述。

write_community

字符串

snmp_v2c_write 写入团体。

密码不能包含空格或尖括号 (< >)。

snmp_v3

列表 / 元素=字典

全局凭证 V2 的 snmpV3。

auth_password

字符串

snmp_v3 身份验证密码。

密码必须至少包含 8 个字符。

密码不能包含空格或尖括号 (< >)。

auth_type

字符串

身份验证类型。[“SHA”、“MD5”]。

description

字符串

snmp_v3 描述。

应与其他 snmp_v3 凭证不同。

id

字符串

凭证 ID。使用此 ID 更新设备凭证。

old_description

字符串

旧描述。使用此项更新描述。

privacy_password

字符串

snmp_v3 隐私密码。

密码必须至少包含 8 个字符。

密码不能包含空格或尖括号 (< >)。

privacy_type

字符串

隐私类型。[“AES128”、“AES192”、“AES256”]。

snmp_mode

字符串

Snmp 模式。[“AUTHPRIV”、“AUTHNOPRIV”、“NOAUTHNOPRIV”]。

username

字符串

snmp_v3 凭证用户名。

用户名不能包含空格或尖括号 (< >)。

config_verify

布尔值

设置为 True 可在应用 playbook 配置后验证 Cisco DNA Center。

选项

  • false ← (默认)

  • true

dnac_api_task_timeout

整数

定义用于检索任务详细信息的 API 调用的超时时间(以秒为单位)。如果在此期间未收到任务详细信息,则该过程将结束,并记录超时通知。

默认值: 1200

dnac_debug

布尔值

Cisco DNA Center SDK 启用调试的标志。

选项

  • false ← (默认)

  • true

dnac_host

字符串 / 必需

Cisco DNA Center 主机名。

dnac_log

布尔值

启用/禁用 playbook 执行日志记录的标志。

当为 true 且提供了 dnac_log_file_path 时,- 在执行位置使用指定的名称创建日志文件。

当为 true 且未提供 dnac_log_file_path 时,- 在执行位置创建名称为“dnac.log”的日志文件。

当为 false 时,- 禁用日志记录。

如果日志文件不存在,- 将根据“dnac_log_append”标志,以追加或写入模式创建该文件。

如果日志文件存在,- 将根据“dnac_log_append”标志,覆盖或追加该文件。

选项

  • false ← (默认)

  • true

dnac_log_append

布尔值

确定文件的模式。设置为 True 表示“追加”模式。设置为 False 表示“写入”模式。

选项

  • false

  • true ← (默认)

dnac_log_file_path

字符串

控制日志记录。如果 dnac_log 为 True,则记录日志。

如果未指定路径,- 当“dnac_log_append”为 True 时,将在当前 Ansible 目录中生成“dnac.log”;日志将被追加。- 当“dnac_log_append”为 False 时,将生成“dnac.log”;日志将被覆盖。

如果指定了路径,- 当“dnac_log_append”为 True 时,文件将以追加模式打开。- 当“dnac_log_append”为 False 时,文件将以写入 (w) 模式打开。- 在共享文件场景中,如果不使用追加模式,内容将在每次模块执行后被覆盖。- 对于共享日志文件,第一个模块的追加设置为 False(以覆盖);对于后续模块,追加设置为 True。

默认值: "dnac.log"

dnac_log_level

字符串

设置日志级别的阈值。级别等于或高于此阈值的消息将被记录。级别按严重性顺序列出 [CRITICAL, ERROR, WARNING, INFO, DEBUG]。

CRITICAL 表示会导致程序停止的严重错误。仅显示 CRITICAL 消息。

ERROR 表示阻止函数执行的问题。显示 ERROR 和 CRITICAL 消息。

WARNING 表示潜在的未来问题。显示 WARNING、ERROR 和 CRITICAL 消息。

INFO 跟踪正常操作。显示 INFO、WARNING、ERROR 和 CRITICAL 消息。

DEBUG 提供详细的诊断信息。显示所有日志消息。

默认值: "WARNING"

dnac_password

字符串

用于身份验证的 Cisco DNA Center 密码。

dnac_port

字符串

Cisco DNA Center 端口。

默认值: "443"

dnac_task_poll_interval

整数

指定连续调用 API 以检索任务详细信息的时间间隔(秒)。

默认值: 2

dnac_username

别名: user

字符串

用于身份验证的 Cisco DNA Center 用户名。

默认值: "admin"

dnac_verify

布尔值

启用或禁用 SSL 证书验证的标志。

选项

  • false

  • true ← (默认)

dnac_version

字符串

通知 SDK 使用哪个版本的 Cisco DNA Center。

默认值: "2.2.3.3"

state

字符串

模块完成后 Cisco DNA Center 的状态。

选项

  • "merged" ← (默认)

  • "deleted"

validate_response_schema

布尔值

Cisco DNA Center SDK 的标志,用于启用针对 JSON 模式验证请求体。

选项

  • false

  • true ← (默认)

备注

注意

  • 使用的 SDK 方法为 discovery.Discovery.create_global_credentials_v2, discovery.Discovery.delete_global_credential_v2, discovery.Discovery.update_global_credentials_v2, network_settings.NetworkSettings.assign_device_credential_to_site_v2,

  • 使用的路径为 post /dna/intent/api/v2/global-credential, delete /dna/intent/api/v2/global-credential/{id}, put /dna/intent/api/v2/global-credential, post /dna/intent/api/v2/credential-to-site/{siteId},

  • 不支持 check_mode

  • 该插件在控制节点上运行,不使用任何 ansible 连接插件,而是使用 Cisco DNAC SDK 中的嵌入式连接管理器

  • 以 dnac_ 开头的参数由 Cisco DNAC Python SDK 用于建立连接

另请参阅

另请参阅

Cisco DNA Center 文档,关于 Discovery CreateGlobalCredentialsV2

CreateGlobalCredentialsV2 API 的完整参考。

Cisco DNA Center 文档,关于 Discovery DeleteGlobalCredentialV2

DeleteGlobalCredentialV2 API 的完整参考。

Cisco DNA Center 文档,关于 Discovery UpdateGlobalCredentialsV2

UpdateGlobalCredentialsV2 API 的完整参考。

Cisco DNA Center 文档,关于 Network Settings AssignDeviceCredentialToSiteV2

AssignDeviceCredentialToSiteV2 API 的完整参考。

示例

---
  - name: Create Credentials and assign it to a site.
    cisco.dnac.device_credential_intent:
    dnac_host: "{{ dnac_host }}"
    dnac_port: "{{ dnac_port }}"
    dnac_username: "{{ dnac_username }}"
    dnac_password: "{{ dnac_password }}"
    dnac_verify: "{{ dnac_verify }}"
    dnac_debug: "{{ dnac_debug }}"
    dnac_log: True
    dnac_log_level: "{{ dnac_log_level }}"
    state: merged
    config_verify: True
    config:
    - global_credential_details:
        cli_credential:
        - description: string
          username: string
          password: string
          enable_password: string
        snmp_v2c_read:
        - description: string
          read_community: string
        snmp_v2c_write:
        - description: string
          write_community: string
        snmp_v3:
        - auth_password: string
          auth_type: SHA
          snmp_mode: AUTHPRIV
          privacy_password: string
          privacy_type: AES128
          username: string
          description: string
        https_read:
        - description: string
          username: string
          password: string
          port: 443
        https_write:
        - description: string
          username: string
          password: string
          port: 443
      assign_credentials_to_site:
        cli_credential:
          id: string
        snmp_v2c_read:
          id: string
        snmp_v2c_write:
          id: string
        snmp_v3:
          id: string
        https_read:
          id: string
        https_write:
           id: string
        site_name:
        - string

  - name: Create Multiple Credentials.
    cisco.dnac.device_credential_intent:
    dnac_host: "{{ dnac_host }}"
    dnac_port: "{{ dnac_port }}"
    dnac_username: "{{ dnac_username }}"
    dnac_password: "{{ dnac_password }}"
    dnac_verify: "{{ dnac_verify }}"
    dnac_debug: "{{ dnac_debug }}"
    dnac_log: True
    dnac_log_level: "{{ dnac_log_level }}"
    state: merged
    config_verify: True
    config:
    - global_credential_details:
        cli_credential:
        - description: string
          username: string
          password: string
          enable_password: string
        - description: string
          username: string
          password: string
          enable_password: string
        snmp_v2c_read:
        - description: string
          read_community: string
        - description: string
          read_community: string
        snmp_v2c_write:
        - description: string
          write_community: string
        - description: string
          write_community: string
        snmp_v3:
        - auth_password: string
          auth_type: SHA
          snmp_mode: AUTHPRIV
          privacy_password: string
          privacy_type: AES128
          username: string
          description: string
        - auth_password: string
          auth_type: SHA
          snmp_mode: AUTHPRIV
          privacy_password: string
          privacy_type: AES128
          username: string
          description: string
        https_read:
        - description: string
          username: string
          password: string
          port: 443
        - description: string
          username: string
          password: string
          port: 443
        https_write:
        - description: string
          username: string
          password: string
          port: 443
        - description: string
          username: string
          password: string
          port: 443

  - name: Update global device credentials using id
    cisco.dnac.device_credential_intent:
    dnac_host: "{{ dnac_host }}"
    dnac_port: "{{ dnac_port }}"
    dnac_username: "{{ dnac_username }}"
    dnac_password: "{{ dnac_password }}"
    dnac_verify: "{{ dnac_verify }}"
    dnac_debug: "{{ dnac_debug }}"
    dnac_log: True
    dnac_log_level: "{{ dnac_log_level }}"
    state: merged
    config_verify: True
    config:
    - global_credential_details:
        cli_credential:
        - description: string
          username: string
          password: string
          enable_password: string
          id: string
        snmp_v2c_read:
        - description: string
          read_community: string
          id: string
        snmp_v2c_write:
        - description: string
          write_community: string
          id: string
        snmp_v3:
        - auth_password: string
          auth_type: SHA
          snmp_mode: AUTHPRIV
          privacy_password: string
          privacy_type: AES128
          username: string
          description: string
          id: string
        https_read:
        - description: string
          username: string
          password: string
          port: 443
          id: string
        https_write:
        - description: string
          username: string
          password: string
          port: 443
          id: string

  - name: Update multiple global device credentials using id
    cisco.dnac.device_credential_intent:
    dnac_host: "{{ dnac_host }}"
    dnac_port: "{{ dnac_port }}"
    dnac_username: "{{ dnac_username }}"
    dnac_password: "{{ dnac_password }}"
    dnac_verify: "{{ dnac_verify }}"
    dnac_debug: "{{ dnac_debug }}"
    dnac_log: True
    dnac_log_level: "{{ dnac_log_level }}"
    state: merged
    config_verify: True
    config:
    - global_credential_details:
        cli_credential:
        - description: string
          username: string
          password: string
          enable_password: string
          id: string
        - description: string
          username: string
          password: string
          enable_password: string
          id: string
        snmp_v2c_read:
        - description: string
          read_community: string
          id: string
        - description: string
          read_community: string
          id: string
        snmp_v2c_write:
        - description: string
          write_community: string
          id: string
        - description: string
          write_community: string
          id: string
        snmp_v3:
        - auth_password: string
          auth_type: SHA
          snmp_mode: AUTHPRIV
          privacy_password: string
          privacy_type: AES128
          username: string
          description: string
          id: string
        - auth_password: string
          auth_type: SHA
          snmp_mode: AUTHPRIV
          privacy_password: string
          privacy_type: AES128
          username: string
          description: string
          id: string
        https_read:
        - description: string
          username: string
          password: string
          port: 443
          id: string
        - description: string
          username: string
          password: string
          port: 443
          id: string
        https_write:
        - description: string
          username: string
          password: string
          port: 443
          id: string
        - description: string
          username: string
          password: string
          port: 443
          id: string

  - name: Update global device credential name/description using old name and description.
    cisco.dnac.device_credential_intent:
    dnac_host: "{{ dnac_host }}"
    dnac_port: "{{ dnac_port }}"
    dnac_username: "{{ dnac_username }}"
    dnac_password: "{{ dnac_password }}"
    dnac_verify: "{{ dnac_verify }}"
    dnac_debug: "{{ dnac_debug }}"
    dnac_log: True
    dnac_log_level: "{{ dnac_log_level }}"
    state: merged
    config_verify: True
    config:
    - global_credential_details:
        cli_credential:
        - description: string
          username: string
          password: string
          enable_password: string
          old_description: string
          old_username: string
        snmp_v2c_read:
        - description: string
          read_community: string
          old_description: string
        snmp_v2c_write:
        - description: string
          write_community: string
          old_description: string
        snmp_v3:
        - auth_password: string
          auth_type: string
          snmp_mode: string
          privacy_password: string
          privacy_type: string
          username: string
          description: string
        https_read:
        - description: string
          username: string
          password: string
          port: string
          old_description: string
          old_username: string
        https_write:
        - description: string
          username: string
          password: string
          port: string
          old_description: string
          old_username: string

  - name: Assign Credentials to sites using old description and username.
    cisco.dnac.device_credential_intent:
    dnac_host: "{{ dnac_host }}"
    dnac_port: "{{ dnac_port }}"
    dnac_username: "{{ dnac_username }}"
    dnac_password: "{{ dnac_password }}"
    dnac_verify: "{{ dnac_verify }}"
    dnac_debug: "{{ dnac_debug }}"
    dnac_log: True
    dnac_log_level: "{{ dnac_log_level }}"
    state: merged
    config_verify: True
    config:
    - assign_credentials_to_site:
        cli_credential:
          description: string
          username: string
        snmp_v2c_read:
          description: string
        snmp_v2c_write:
          description: string
        snmp_v3:
          description: string
        https_read:
          description: string
          username: string
        https_write:
          description: string
          username: string
        site_name:
        - string
        - string

返回值

常用返回值记录在这里,以下是此模块特有的字段

描述

dnac_response1

字典

一个字典或列表,包含 Cisco DNAC Python SDK 返回的响应

返回: 始终

示例: {"response": {"taskId": "string", "url": "string"}, "version": "string"}

dnac_response2

字典

一个字典或列表,包含 Cisco DNAC Python SDK 返回的响应

返回: 始终

示例: {"response": {"taskId": "string", "url": "string"}, "version": "string"}

作者

  • Muthu Rakesh (@MUTHU-RAKESH-27) Madhan Sankaranarayanan (@madhansansel)