community.digitalocean.digital_ocean_certificate 模块 – 在 DigitalOcean 中管理证书

注意

此模块是 community.digitalocean 集合 (版本 1.27.0) 的一部分。

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

要安装它,请使用: ansible-galaxy collection install community.digitalocean

要在 playbook 中使用它,请指定: community.digitalocean.digital_ocean_certificate

概要

  • 创建、检索和删除 DigitalOcean 证书。

参数

参数

注释

baseurl

字符串

DigitalOcean API 基本 URL。

默认值: "https://api.digitalocean.com/v2"

certificate_chain

字符串

证书颁发机构证书和您的域的 SSL 证书之间的完整 PEM 格式信任链。

leaf_certificate

字符串

PEM 格式的公共 SSL 证书。

name

字符串 / 必需

证书的名称。

oauth_token

别名:api_token

字符串

DigitalOcean OAuth 令牌。

可以使用多个其他环境变量来提供此值。

例如 - DO_API_TOKENDO_API_KEYDO_OAUTH_TOKENOAUTH_TOKEN

private_key

字符串

PEM 格式的 SSL 证书私钥内容。

state

字符串

证书是否存在。

选项

  • "present" ← (默认)

  • "absent"

timeout

整数

用于轮询 DigitalOcean API 的超时时间(秒)。

默认值: 30

validate_certs

布尔值

如果设置为 no,则不会验证 SSL 证书。

只有在使用自签名证书的个人控制站点上才应将其设置为 no

选项

  • false

  • true ← (默认)

备注

注意

  • 可以使用两个环境变量 DO_API_KEY、DO_OAUTH_TOKEN 和 DO_API_TOKEN。它们都指的是 v2 令牌。

示例

- name: Create a certificate
  community.digitalocean.digital_ocean_certificate:
    name: production
    state: present
    private_key: "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkM8OI7pRpgyj1I\n-----END PRIVATE KEY-----"
    leaf_certificate: "-----BEGIN CERTIFICATE-----\nMIIFDmg2Iaw==\n-----END CERTIFICATE-----"
    oauth_token: b7d03a6947b217efb6f3ec3bd365652

- name: Create a certificate using file lookup plugin
  community.digitalocean.digital_ocean_certificate:
    name: production
    state: present
    private_key: "{{ lookup('file', 'test.key') }}"
    leaf_certificate: "{{ lookup('file', 'test.cert') }}"
    oauth_token: "{{ oauth_token }}"

- name: Create a certificate with trust chain
  community.digitalocean.digital_ocean_certificate:
    name: production
    state: present
    private_key: "{{ lookup('file', 'test.key') }}"
    leaf_certificate: "{{ lookup('file', 'test.cert') }}"
    certificate_chain: "{{ lookup('file', 'chain.cert') }}"
    oauth_token: "{{ oauth_token }}"

- name: Remove a certificate
  community.digitalocean.digital_ocean_certificate:
    name: production
    state: absent
    oauth_token: "{{ oauth_token }}"

作者

  • Abhijeet Kasurde (@Akasurde)