community.digitalocean.digital_ocean_sshkey_info 模块 – 收集 DigitalOcean SSH 密钥信息
注意
此模块是 community.digitalocean 集合 (版本 1.27.0) 的一部分。
如果您正在使用 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install community.digitalocean。您需要其他要求才能使用此模块,请参阅 要求 以了解详情。
要在 playbook 中使用它,请指定:community.digitalocean.digital_ocean_sshkey_info。
概要
- 此模块可用于收集有关 DigitalOcean SSH 密钥的信息。 
- 此模块替换 - digital_ocean_sshkey_facts模块。
别名:digital_ocean_sshkey_facts
要求
在执行此模块的主机上需要以下要求。
- python >= 2.6 
参数
| 参数 | 注释 | 
|---|---|
| DigitalOcean API 基本 URL。 默认值:  | |
| DigitalOcean OAuth 令牌。 可以使用其他几个环境变量来提供此值。 例如,-  | |
| 用于轮询 DigitalOcean API 的超时时间(秒)。 默认值:  | |
| 如果设置为  仅在使用自签名证书的个人控制站点上才应将其设置为  选项 
 | 
备注
注意
- 使用 DigitalOcean API 的版本 2。 
示例
- name: Gather information about DigitalOcean SSH keys
  community.digitalocean.digital_ocean_sshkey_info:
    oauth_token: "{{ my_do_key }}"
  register: ssh_keys
- name: Set facts based on the gathered information
  set_fact:
    pubkey: "{{ item.public_key }}"
  loop: "{{ ssh_keys.data | community.general.json_query(ssh_pubkey) }}"
  vars:
    ssh_pubkey: "[?name=='ansible_ctrl']"
- name: Print SSH public key
  debug:
    msg: "{{ pubkey }}"
返回值
常见的返回值已记录在 此处,以下是此模块特有的字段
| 键 | 描述 | 
|---|---|
| DigitalOcean 上的 SSH 密钥列表 返回:成功且无资源限制 示例:  | 
