usegalaxy_eu.certbot

Ansible 角色:Certbot(用于 Let's Encrypt)

构建状态

安装和配置 Certbot(用于 Let's Encrypt)。

需求

如果从源代码安装,则需要 Git。您可以使用 geerlingguy.git 角色安装 Git。

角色变量

变量 certbot_install_from_source 控制是否从 Git 或包管理安装 Certbot。后者是默认设置,因此变量默认值为 no

certbot_auto_renew: true
certbot_auto_renew_user: "{{ ansible_user }}"
certbot_auto_renew_hour: 3
certbot_auto_renew_minute: 30

默认情况下,此角色配置一个 cron 任务,每天在指定的小时和分钟以所提供的用户帐户运行。默认情况下,该任务在每天 03:30:00 由 Ansible 剧本中使用的用户运行 certbot renew(或 certbot-auto renew)。建议您设置自定义用户/小时/分钟,以便在流量较少的时间进行续订,并由非 root 用户帐户执行。

从 Git 源安装

如果需要,您可以从 Git 源代码库安装 Certbot。这在某些情况下可能会有用,特别是当旧版本的发行版没有 Certbot 包可用时(例如,CentOS < 7,Ubuntu < 16.10 和 Debian < 8)。

certbot_install_from_source: no
certbot_repo: https://github.com/certbot/certbot.git
certbot_version: master
certbot_keep_updated: yes

Certbot Git 仓库选项。要从源代码安装,请将 certbot_install_from_source 设置为 yes。这将克隆配置的 certbot_repo,尊重 certbot_version 设置。如果将 certbot_keep_updated 设置为 yes,每次运行此角色时,都会更新该仓库。

certbot_dir: /opt/certbot

Certbot 将被克隆到的目录。

DNS 提供商

如果您使用 Cloudflare 或类似的 DNS 提供商,则可以使用以下变量:

certbot_dns_provider: cloudflare
certbot_dns_credentials:
    api_token: your_dns_provider_api_token
certbot_dns_provider_propagation_seconds: 60

certbot_dns_credentials 的有效选项因 DNS 提供商而异。有关详细信息,请查看 certbot --help all

依赖

无。

示例剧本

- hosts: servers

  vars:
    certbot_auto_renew_user: your_username_here
    certbot_auto_renew_minute: 20
    certbot_auto_renew_hour: 5
    # certbot_agree_tos: "--agree-tos" # 取消注释以表示同意
  roles:
    - geerlingguy.certbot

安装后,您可以使用 certbot(或 certbot-auto)脚本创建证书,该脚本默认安装在配置的 certbot_dir 中(使用 Git 时)。以下是一些使用 Certbot 配置证书的示例命令:

# 自动为所有 Apache 虚拟主机添加证书(使用时请谨慎)。
/opt/certbot/certbot-auto --apache

# 生成证书,但不修改 Apache 配置(更安全)。
/opt/certbot/certbot-auto --apache certonly

默认情况下,此角色添加一个 cron 任务,每天在您选择的小时和分钟续订所有安装的证书。

您可以使用以下命令测试自动续订(不实际续订证书):

/opt/certbot/certbot-auto renew --dry-run

有关完整文档和选项,请访问 Certbot 网站

许可证

MIT / BSD

作者信息

安装
ansible-galaxy install usegalaxy_eu.certbot
许可证
mit
下载
9.8k
拥有者