File tree Expand file tree Collapse file tree 2 files changed +18
-8
lines changed
Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ certbot_certs: []
1818# - domains:
1919# - example3.com
2020certbot_create_command : >-
21- {{ certbot_script }} certonly --standalone --noninteractive --agree-tos
21+ {{ certbot_script }} certonly --standalone --noninteractive --expand -- agree-tos
2222 --email {{ cert_item.email | default(certbot_admin_email) }}
2323 -d {{ cert_item.domains | join(',') }}
2424
Original file line number Diff line number Diff line change 11---
2- - name : Check if certificate already exists.
3- stat :
4- path : /etc/letsencrypt/live/{{ cert_item.domains | first | replace('*.', '') }}/cert.pem
5- register : letsencrypt_cert
2+ - name : Get installed certs.
3+ shell : ' {{ certbot_script }} certificates | grep "Domains:" | awk '' { gsub(/ Domains: /,""); print }'' '
4+ changed_when : false
5+ register : letsencrypt_certs
6+
7+ - name : Set cert_exists to false (to check if cert exists).
8+ set_fact :
9+ cert_exists : false
10+
11+ - name : Check if the cert exists.
12+ set_fact :
13+ cert_exists : true
14+ when : cert_item.domains | sort | difference(item) == []
15+ with_list : " {{ letsencrypt_certs.stdout_lines }}"
616
717- name : Stop services to allow certbot to generate a cert.
818 service :
919 name : " {{ item }}"
1020 state : stopped
11- when : not letsencrypt_cert.stat.exists
21+ when : cert_exists | default(false) | bool == false
1222 with_items : " {{ certbot_create_standalone_stop_services }}"
1323
1424- name : Generate new certificate if one doesn't exist.
1525 command : " {{ certbot_create_command }}"
16- when : not letsencrypt_cert.stat.exists
26+ when : cert_exists | default(false) | bool == false
1727
1828- name : Start services after cert has been generated.
1929 service :
2030 name : " {{ item }}"
2131 state : started
22- when : not letsencrypt_cert.stat.exists
32+ when : cert_exists | default(false) | bool == false
2333 with_items : " {{ certbot_create_standalone_stop_services }}"
You can’t perform that action at this time.
0 commit comments