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

Compare defined cert domains to existing #68

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
18 changes: 13 additions & 5 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,26 @@
follow: yes
become: yes

- name: Check is the cert domains changed
lineinfile:
path: "/etc/letsencrypt/renewal/{{ letsencrypt_cert_domains[0] }}.conf"
line: "{{ '%s = %s' % ( 'cert_domains', ( letsencrypt_cert_domains | to_yaml | from_yaml ) ) }}"
state: present
check_mode: yes
register: is_cert_domains
failed_when: no
changed_when: is_cert_domains.changed or ( is_cert_domains.rc is defined and is_cert_domains.rc != 0 )

- name: Attempt to get the certificate using the webroot authenticator
command: "{{ letsencrypt_command }} -a webroot --webroot-path {{ letsencrypt_webroot_path }} certonly"
become: yes
args:
creates: "/etc/letsencrypt/live/{{ letsencrypt_cert_domains[0] }}"
when: letsencrypt_authenticator == "webroot"
when: letsencrypt_authenticator == "webroot" and is_cert_domains.changed
ignore_errors: True

- name: Attempt to get the certificate using the standalone authenticator (in case eg the webserver isn't running yet)
command: "{{ letsencrypt_command }} -a standalone auth {{ letsencrypt_standalone_command_args }}"
become: yes
args:
creates: "/etc/letsencrypt/live/{{ letsencrypt_cert_domains[0] }}"
when: letsencrypt_authenticator != 'webroot' and is_cert_domains.changed

- name: Fix the renewal file
ini_file:
Expand All @@ -64,6 +71,7 @@
uir: False
hsts: False
authenticator: '{{ letsencrypt_authenticator }}'
cert_domains: '{{ letsencrypt_cert_domains }}'

- name: Fix the webroot map in the renewal file
ini_file:
Expand Down