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
a4a25f8139
commit
ed6fa4419a
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.
|
- include_tasks: check-existence.yml
|
||||||
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 }}"
|
|
||||||
|
|
||||||
- name: Ensure pre and post hook folders exist.
|
- name: Ensure pre and post hook folders exist.
|
||||||
file:
|
file:
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
---
|
---
|
||||||
- name: Check if certificate already exists.
|
- include_tasks: check-existence.yml
|
||||||
stat:
|
|
||||||
path: /etc/letsencrypt/live/{{ cert_item.domains | first }}/cert.pem
|
|
||||||
register: letsencrypt_cert
|
|
||||||
|
|
||||||
- name: Create webroot directory if it doesn't exist yet
|
- name: Create webroot directory if it doesn't exist yet
|
||||||
file:
|
file:
|
||||||
@ -11,4 +8,4 @@
|
|||||||
|
|
||||||
- name: Generate new certificate if one doesn't exist.
|
- name: Generate new certificate if one doesn't exist.
|
||||||
command: "{{ certbot_create_command }}"
|
command: "{{ certbot_create_command }}"
|
||||||
when: not letsencrypt_cert.stat.exists
|
when: not cert_exists
|
||||||
|
Loading…
x
Reference in New Issue
Block a user