Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for certificates to be expanded to include new domains #208

Merged
merged 1 commit into from
Jan 29, 2025
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 protected]
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"
Loading