Certbot: handlers #1
2 changed files with 11 additions and 17 deletions
8
roles/certbot/handlers/main.yml
Normal file
8
roles/certbot/handlers/main.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
- name: Reload nginx
|
||||||
|
service:
|
||||||
|
name: nginx
|
||||||
|
state: reloaded
|
||||||
|
|
||||||
|
- name: Generate certificates
|
||||||
|
command: "certbot certonly --non-interactive --config /etc/letsencrypt/conf.d/{{ certbot.certname }}.ini"
|
|
@ -20,20 +20,6 @@
|
||||||
src: "letsencrypt/conf.d/certname.ini.j2"
|
src: "letsencrypt/conf.d/certname.ini.j2"
|
||||||
dest: "/etc/letsencrypt/conf.d/{{ certbot.certname }}.ini"
|
dest: "/etc/letsencrypt/conf.d/{{ certbot.certname }}.ini"
|
||||||
mode: 0644
|
mode: 0644
|
||||||
register: certbot_config
|
notify:
|
||||||
|
- Generate certificates
|
||||||
- name: Stop services to allow certbot to generate a cert.
|
- Reload nginx
|
||||||
service:
|
|
||||||
name: nginx
|
|
||||||
state: stopped
|
|
||||||
when: certbot_config.changed
|
|
||||||
|
|
||||||
- name: Generate new certificate if the configuration changed
|
|
||||||
shell: "certbot certonly --non-interactive --config /etc/letsencrypt/conf.d/{{ certbot.certname }}.ini"
|
|
||||||
when: certbot_config.changed
|
|
||||||
|
|
||||||
- name: Restart services to allow certbot to generate a cert.
|
|
||||||
service:
|
|
||||||
name: nginx
|
|
||||||
state: started
|
|
||||||
when: certbot_config.changed
|
|
||||||
|
|
Loading…
Reference in a new issue