thermistor.acme_sh

当前标签

acme_sh

通过 ansible 在 dns api 模式下设置 acme.sh,以生成 letsencrypt.org 证书。

依赖

许多默认设置假设使用 nginx。

变量

以下是一些控制行为的默认设置:

acme_sh_autoupgrade: True
acme_sh_server: letsencrypt
acme_sh_notify: False
acme_sh_logging: False
acme_sh_keylength: 4096
acme_sh_dns_sleep: 120

acme_sh_certs_public_dir: /etc/nginx/certs
acme_sh_certs_private_dir: /etc/nginx/private
acme_sh_reload_cmd: /bin/systemctl reload nginx

实例剧本

以下是使用 AWS Route53 API 的示例。但您可以根据任何 DNS API 提供商进行修改。

用法:

- hosts: servers
  roles:
    - role: thermistor.acme_sh
      acme_sh_subject_names:
        - example.com
        - www.example.com
      acme_sh_dns_provider: dns_aws
      acme_sh_env:
        AWS_ACCESS_KEY_ID: "{{ your_vault_aws_access_key_id }}"
        AWS_SECRET_ACCESS_KEY: "{{ your_vault_aws_secret_access_key }}"

这是相同示例,但添加了日志记录:

- hosts: servers
  roles:
    - role: thermistor.acme_sh
      acme_sh_logging: True
      acme_sh_subject_names:
        - example.com
        - www.example.com
      acme_sh_dns_provider: dns_aws
      acme_sh_env:
        AWS_ACCESS_KEY_ID: "{{ your_vault_aws_access_key_id }}"
        AWS_SECRET_ACCESS_KEY: "{{ your_vault_aws_secret_access_key }}"

以及使用 mailgun 通知的示例:

- hosts: servers
  roles:
    - role: thermistor.acme_sh
      acme_sh_notify: True
      acme_sh_notify_hooks:
        - mailgun
      acme_sh_subject_names:
        - example.com
        - www.example.com
      acme_sh_dns_provider: dns_aws
      acme_sh_env:
        AWS_ACCESS_KEY_ID: "{{ your_vault_aws_access_key_id }}"
        AWS_SECRET_ACCESS_KEY: "{{ your_vault_aws_secret_access_key }}"
        MAILGUN_API_KEY: "{{ your_vault_mailgun_api_key }}"
        MAILGUN_API_DOMAIN: "{{ your_vault_mailgun_domain }}"
        MAILGUN_FROM: "{{ your_vault_mailgun_from }}"
        MAILGUN_TO: "{{ your_vault_mailgun_to }}"

背后发生的事情

如果您为 example.com 生成证书,在安装步骤期间,此角色将复制 /var/lib/acme/.acme.sh/example.com/fullchain.cer 并将其安装为 /etc/nginx/certs/example.com.cer。请注意,它正在安装 fullchain 证书并重命名,这样您就可以根据需要为不同域名安装多个 fullchain 证书。

故障排除

如果存在证书配置错误,有时您可能会进入一个证书未重新安装的困境,您可以通过以下命令强制重新安装证书:

ansible-playbook -i inventory playbook.yml -e "acme_sh_force_install=True" --tags acme_sh_cert_install

许可证

MIT

替代方案

我们借鉴了许多这些替代方案:

关于项目

Configure acme.sh

安装
ansible-galaxy install thermistor.acme_sh
许可证
Unknown
下载
177
拥有者
Product guy