Move services start into a handler

when running temporary invalid nginx configuration
This commit is contained in:
Alexis Leclerc 2021-05-27 12:05:31 +02:00
parent 70b33ab511
commit 27aa351bfe
No known key found for this signature in database
GPG Key ID: AB062C89CCC3E961
2 changed files with 10 additions and 9 deletions

7
handlers/main.yml Normal file
View File

@ -0,0 +1,7 @@
---
- name: start services
service:
name: "{{ item }}"
state: started
when: not letsencrypt_cert.stat.exists
with_items: "{{ certbot_create_standalone_stop_services }}"

View File

@ -1,5 +1,5 @@
--- ---
- name: Check if certificate already exists. - name: Check if certificate already exists. ({{ cert_item.domains }})
stat: stat:
path: /etc/letsencrypt/live/{{ cert_item.domains | first | replace('*.', '') }}/cert.pem path: /etc/letsencrypt/live/{{ cert_item.domains | first | replace('*.', '') }}/cert.pem
register: letsencrypt_cert register: letsencrypt_cert
@ -11,13 +11,7 @@
when: not letsencrypt_cert.stat.exists when: not letsencrypt_cert.stat.exists
with_items: "{{ certbot_create_standalone_stop_services }}" with_items: "{{ certbot_create_standalone_stop_services }}"
- name: Generate new certificate if one doesn't exist. - name: Generate new certificate if one doesn't exist. ({{ cert_item.domains }})
command: "{{ certbot_create_command }}" command: "{{ certbot_create_command }}"
when: not letsencrypt_cert.stat.exists when: not letsencrypt_cert.stat.exists
notify: start services
- name: Start services after cert has been generated.
service:
name: "{{ item }}"
state: started
when: not letsencrypt_cert.stat.exists
with_items: "{{ certbot_create_standalone_stop_services }}"