community.crypto.acme_challenge_cert_helper 模块 – 为 ACME 挑战(例如 tls-alpn-01)准备所需的证书

注意

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

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

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

要在剧本中使用它,请指定:community.crypto.acme_challenge_cert_helper

概要

  • 为 ACME 挑战(例如 tls-alpn-01)准备证书。

  • 原始数据由 community.crypto.acme_certificate 模块提供,需要将其转换为证书才能用于挑战验证。此模块提供了一种简单的方法来生成所需的证书。

需求

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

  • cryptography >= 1.3

参数

参数

注释

challenge

字符串 / 必需

挑战类型。

选项

  • "tls-alpn-01"

challenge_data

字典 / 必需

community.crypto.acme_certificate 为挑战提供的 challenge_data 条目。

private_key_content

字符串

要用于此挑战证书的私钥内容。

private_key_src 互斥。

private_key_passphrase

字符串

在 community.crypto 1.6.0 中添加

用于解码私钥的密码。

private_key_src

路径

包含要用于此挑战证书的私钥文件的路径。

private_key_content 互斥。

属性

属性

支持

描述

check_mode

支持:不支持

此操作不会修改状态。

可以在 check_mode 中运行并返回更改状态预测,而无需修改目标。

diff_mode

支持: N/A

此操作不会修改状态。

在差异模式下,将返回有关已更改内容(或可能需要在 check_mode 中更改的内容)的详细信息。

另请参阅

另请参阅

自动证书管理环境 (ACME)

ACME 协议规范 (RFC 8555)。

ACME TLS ALPN 挑战扩展

tls-alpn-01 挑战规范 (RFC 8737)。

示例

- name: Create challenges for a given CRT for sample.com
  community.crypto.acme_certificate:
    account_key_src: /etc/pki/cert/private/account.key
    challenge: tls-alpn-01
    csr: /etc/pki/cert/csr/sample.com.csr
    dest: /etc/httpd/ssl/sample.com.crt
  register: sample_com_challenge

- name: Create certificates for challenges
  community.crypto.acme_challenge_cert_helper:
    challenge: tls-alpn-01
    challenge_data: "{{ item.value['tls-alpn-01'] }}"
    private_key_src: /etc/pki/cert/key/sample.com.key
  loop: "{{ sample_com_challenge.challenge_data | dictsort }}"
  register: sample_com_challenge_certs

- name: Install challenge certificates
  # We need to set up HTTPS such that for the domain,
  # regular_certificate is delivered for regular connections,
  # except if ALPN selects the "acme-tls/1"; then, the
  # challenge_certificate must be delivered.
  # This can for example be achieved with very new versions
  # of NGINX; search for ssl_preread and
  # ssl_preread_alpn_protocols for information on how to
  # route by ALPN protocol.
  ...:
    domain: "{{ item.domain }}"
    challenge_certificate: "{{ item.challenge_certificate }}"
    regular_certificate: "{{ item.regular_certificate }}"
    private_key: /etc/pki/cert/key/sample.com.key
  loop: "{{ sample_com_challenge_certs.results }}"

- name: Create certificate for a given CSR for sample.com
  community.crypto.acme_certificate:
    account_key_src: /etc/pki/cert/private/account.key
    challenge: tls-alpn-01
    csr: /etc/pki/cert/csr/sample.com.csr
    dest: /etc/httpd/ssl/sample.com.crt
    data: "{{ sample_com_challenge }}"

返回值

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

描述

challenge_certificate

字符串

挑战证书的 PEM 格式。

返回:始终

domain

字符串

挑战的目标域名。如果在请求的 Host 头中指定了此域名,则应提供证书。

返回:始终

identifier

字符串

实际资源的标识符。如果 identifier_type=dns,则为域名;如果 identifier_type=ip,则为 IP 地址。

返回:始终

identifier_type

字符串

实际资源标识符的标识符类型。

返回:始终

只能返回

  • "dns"

  • "ip"

regular_certificate

字符串

挑战域名的自签名证书。

如果不存在现有证书,则可以在需要提供挑战时用于首先设置 https。

返回:始终

作者

  • Felix Fontein (@felixfontein)