Added method webroot to avoid restarting servers

This commit is contained in:
Valentin Gostev 2019-02-06 22:16:39 +03:00
parent 00dc226101
commit 993e742d5c
4 changed files with 29 additions and 0 deletions

View File

@ -36,3 +36,4 @@ certbot_keep_updated: true
# Where to put Certbot when installing from source.
certbot_dir: /opt/certbot
certbot_webroot: /var/www/letsencrypt

View File

@ -0,0 +1,13 @@
---
- name: Check if certificate already exists.
stat:
path: /etc/letsencrypt/live/{{ cert_item.domains | first | replace('*.', '') }}/cert.pem
register: letsencrypt_cert
- name: Override certbot command variable to use webroot
include_vars: "webroot.yml"
when: not letsencrypt_cert.stat.exists
- name: Generate new certificate if one doesn't exist.
command: "{{ certbot_create_command }}"
when: not letsencrypt_cert.stat.exists

View File

@ -15,5 +15,13 @@
loop_control:
loop_var: cert_item
- include_tasks: create-cert-webroot.yml
with_items: "{{ certbot_certs }}"
when:
- certbot_create_if_missing
- certbot_create_method == 'webroot'
loop_control:
loop_var: cert_item
- import_tasks: renew-cron.yml
when: certbot_auto_renew

7
vars/webroot.yml Normal file
View File

@ -0,0 +1,7 @@
---
certbot_create_command: >-
{{ certbot_script }} certonly --webroot
--webroot-path {{ certbot_webroot }}
--noninteractive --agree-tos
--email {{ cert_item.email | default(certbot_admin_email) }}
-d {{ cert_item.domains | join(',') }}