Restart stop services with handlers on first run to handle situation where service is not yet installed

This commit is contained in:
Michael Baisch 2021-07-03 12:20:49 +02:00
parent 7ad49929dd
commit 3e97fb3756
2 changed files with 8 additions and 6 deletions

View File

@ -21,12 +21,6 @@ certbot_create_command: >-
{{ certbot_script }} certonly --standalone --noninteractive --agree-tos
--email {{ cert_item.email | default(certbot_admin_email) }}
-d {{ cert_item.domains | join(',') }}
{{ '--pre-hook /etc/letsencrypt/renewal-hooks/pre/stop_services'
if certbot_create_standalone_stop_services
else '' }}
{{ '--post-hook /etc/letsencrypt/renewal-hooks/post/start_services'
if certbot_create_standalone_stop_services
else '' }}
certbot_create_standalone_stop_services:
- nginx

View File

@ -40,3 +40,11 @@
- name: Generate new certificate if one doesn't exist.
command: "{{ certbot_create_command }}"
when: not letsencrypt_cert.stat.exists
- name: Restart services after cert has been generated.
debug:
msg: "notify: restart {{ item }}"
notify: "restart {{ item }}"
changed_when: true
with_items: "{{ certbot_create_standalone_stop_services }}"
when: not letsencrypt_cert.stat.exists