Skip to content

Commit

Permalink
Merge pull request #208 from theS1LV3R/master
Browse files Browse the repository at this point in the history
Allow for certificates to be expanded to include new domains
  • Loading branch information
geerlingguy authored Jan 29, 2025
2 parents 98ea323 + 63638f4 commit 9045ec5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
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 protected]
certbot_expand: false

# Default webroot, overwritten by individual per-cert webroot directories
certbot_webroot: /var/www/letsencrypt
Expand All @@ -35,6 +36,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"

0 comments on commit 9045ec5

Please sign in to comment.