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

Add "--expand" option for Certbot #171

Closed
wants to merge 3 commits into from
Closed
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: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ certbot_create_command: >-
--email {{ cert_item.email | default(certbot_admin_email) }}
{{ '--webroot-path ' if certbot_create_method == 'webroot' else '' }}
{{ cert_item.webroot | default(certbot_webroot) if certbot_create_method == 'webroot' else '' }}
-d {{ cert_item.domains | join(',') }}
--domains {{ cert_item.domains | join(',') }} --expand
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you believe the --expand option should be wrapped into another flag which determines its presence?

We are so used to using it all across the board, that we wouldn't even bother to omit it ;]. Do you see any negative impact on just having it as a default?

{{ '--pre-hook /etc/letsencrypt/renewal-hooks/pre/stop_services'
if certbot_create_standalone_stop_services
else '' }}
Expand Down
15 changes: 15 additions & 0 deletions tasks/check-existence.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
- name: Get installed certificates.
command: "{{ certbot_script }} certificates"
changed_when: false
register: letsencrypt_certs

- name: Set cert_exists to false (to check if cert exists).
set_fact:
cert_exists: false

- name: Check if certificate already exists.
set_fact:
cert_exists: true
when: cert_item.domains | sort | difference(item) == []
with_list: "{{ letsencrypt_certs.stdout_lines | select('match', '.*Domains:.*') | map('regex_replace', '^.*Domains: (.*)$', '\\1') }}"
7 changes: 2 additions & 5 deletions tasks/create-cert-standalone.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
---
- name: Check if certificate already exists.
stat:
path: /etc/letsencrypt/live/{{ cert_item.domains | first | replace('*.', '') }}/cert.pem
register: letsencrypt_cert
- include_tasks: check-existence.yml

- name: Ensure pre and post hook folders exist.
file:
Expand Down Expand Up @@ -39,4 +36,4 @@

- name: Generate new certificate if one doesn't exist.
command: "{{ certbot_create_command }}"
when: not letsencrypt_cert.stat.exists
when: not cert_exists
7 changes: 2 additions & 5 deletions tasks/create-cert-webroot.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
---
- name: Check if certificate already exists.
stat:
path: /etc/letsencrypt/live/{{ cert_item.domains | first }}/cert.pem
register: letsencrypt_cert
- include_tasks: check-existence.yml

- name: Create webroot directory if it doesn't exist yet
file:
Expand All @@ -11,4 +8,4 @@

- name: Generate new certificate if one doesn't exist.
command: "{{ certbot_create_command }}"
when: not letsencrypt_cert.stat.exists
when: not cert_exists