File tree Expand file tree Collapse file tree 2 files changed +19
-8
lines changed Expand file tree Collapse file tree 2 files changed +19
-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 : |
4+ {{ certbot_script }} certificates | grep "Domains:" | awk '{ gsub(/ Domains: /,""); print }'
5+ changed_when : false
6+ register : letsencrypt_certs
7+
8+ - name : Set cert_exists to false (to check if cert exists).
9+ set_fact :
10+ cert_exists : false
11+
12+ - name : Check if the cert exists.
13+ set_fact :
14+ cert_exists : true
15+ when : cert_item.domains | sort | difference(item) == []
16+ with_list : " {{ letsencrypt_certs.stdout_lines }}"
617
718- name : Stop services to allow certbot to generate a cert.
819 service :
920 name : " {{ item }}"
1021 state : stopped
11- when : not letsencrypt_cert.stat.exists
22+ when : not cert_exists
1223 with_items : " {{ certbot_create_standalone_stop_services }}"
1324
1425- name : Generate new certificate if one doesn't exist.
1526 command : " {{ certbot_create_command }}"
16- when : not letsencrypt_cert.stat.exists
27+ when : not cert_exists
1728
1829- name : Start services after cert has been generated.
1930 service :
2031 name : " {{ item }}"
2132 state : started
22- when : not letsencrypt_cert.stat.exists
33+ when : not cert_exists
2334 with_items : " {{ certbot_create_standalone_stop_services }}"
You can’t perform that action at this time.
0 commit comments