mirror of
https://github.com/geerlingguy/ansible-role-certbot.git
synced 2025-04-19 17:01:37 +02:00
Allow certificates to be expanded, now also for "webroot" method
This commit is contained in:
parent
d62025267d
commit
95c899b215
16
tasks/check-existence.yml
Normal file
16
tasks/check-existence.yml
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
- name: Get installed certificates.
|
||||
shell: |
|
||||
{{ certbot_script }} certificates | grep "Domains:" | awk '{ gsub(/ Domains: /,""); print }'
|
||||
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 }}"
|
@ -1,19 +1,5 @@
|
||||
---
|
||||
- name: Get installed certificates.
|
||||
shell: |
|
||||
{{ certbot_script }} certificates | grep "Domains:" | awk '{ gsub(/ Domains: /,""); print }'
|
||||
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 }}"
|
||||
- include_tasks: check-existence.yml
|
||||
|
||||
- name: Ensure pre and post hook folders exist.
|
||||
file:
|
||||
|
@ -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:
|
||||
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user