mirror of
https://github.com/geerlingguy/ansible-role-certbot.git
synced 2025-04-19 17:01:37 +02:00
This is useful when you need to stop different services depending on the certificates. For example, if you have a first certificate that uses varnish and a second one using nginx you can have a configuration that looks like this: certbot_certs: - email: janedoe@example.com stop_services: - varnish domains: - example1.com - email: janedoe@example.com stop_services: - nginx domains: - example2.com This way, you don't have to stop both varnish and nginx during cert creation process.
24 lines
815 B
YAML
24 lines
815 B
YAML
---
|
|
- name: Check if certificate already exists.
|
|
stat:
|
|
path: /etc/letsencrypt/live/{{ cert_item.domains | first | replace('*.', '') }}/cert.pem
|
|
register: letsencrypt_cert
|
|
|
|
- name: Stop services to allow certbot to generate a cert.
|
|
service:
|
|
name: "{{ item }}"
|
|
state: stopped
|
|
when: not letsencrypt_cert.stat.exists
|
|
with_items: "{{ cert_item.stop_services | default(certbot_create_standalone_stop_services) }}"
|
|
|
|
- name: Generate new certificate if one doesn't exist.
|
|
command: "{{ certbot_create_command }}"
|
|
when: not letsencrypt_cert.stat.exists
|
|
|
|
- name: Start services after cert has been generated.
|
|
service:
|
|
name: "{{ item }}"
|
|
state: started
|
|
when: not letsencrypt_cert.stat.exists
|
|
with_items: "{{ cert_item.stop_services | default(certbot_create_standalone_stop_services) }}"
|