Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ certbot_hsts: false
certbot_create_if_missing: false
certbot_create_method: standalone
certbot_admin_email: email@example.com
certbot_expand: false

# Default webroot, overwritten by individual per-cert webroot directories
certbot_webroot: /var/www/letsencrypt
Expand All @@ -33,6 +34,7 @@ certbot_create_command: >-
{{ '--test-cert' if certbot_testmode else '' }}
--noninteractive --agree-tos
--email {{ cert_item.email | default(certbot_admin_email) }}
{{ '--expand' if certbot_expand else '' }}
{{ '--webroot-path ' if certbot_create_method == 'webroot' else '' }}
{{ cert_item.webroot | default(certbot_webroot) if certbot_create_method == 'webroot' else '' }}
{{ certbot_create_extra_args }}
Expand Down
8 changes: 2 additions & 6 deletions tasks/create-cert-standalone.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
---
- name: Check if certificate already exists.
stat:
path: /etc/letsencrypt/live/{{ cert_item.domains | first | replace('*.', '') }}/cert.pem
register: letsencrypt_cert

- name: Ensure pre and post hook folders exist.
file:
path: /etc/letsencrypt/renewal-hooks/{{ item }}
Expand Down Expand Up @@ -39,4 +34,5 @@

- name: Generate new certificate if one doesn't exist.
command: "{{ certbot_create_command }}"
when: not letsencrypt_cert.stat.exists
register: certbot_create
changed_when: "'no action taken' not in certbot_create.stdout"
8 changes: 2 additions & 6 deletions tasks/create-cert-webroot.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
---
- name: Check if certificate already exists.
stat:
path: /etc/letsencrypt/live/{{ cert_item.domains | first }}/cert.pem
register: letsencrypt_cert

- name: Create webroot directory if it doesn't exist yet
file:
path: "{{ cert_item.webroot | default(certbot_webroot) }}"
state: directory

- name: Generate new certificate if one doesn't exist.
command: "{{ certbot_create_command }}"
when: not letsencrypt_cert.stat.exists
register: certbot_create
changed_when: "'no action taken' not in certbot_create.stdout"