roles/nginx: Add pre and post hooks for Let's Encrypt on Ubuntu 20.04

Certbot will run any executables in the pre and post directories
during certificate renewal.
This commit is contained in:
Alan Orth 2020-06-06 20:38:08 +03:00
parent 0587841476
commit 9abfe80245
3 changed files with 16 additions and 2 deletions

View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
/bin/systemctl start nginx

View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
/bin/systemctl stop nginx

View File

@ -216,8 +216,16 @@
# On Ubuntu 20.04 it is no longer recommended/supported to use the standalone # On Ubuntu 20.04 it is no longer recommended/supported to use the standalone
# certbot-auto so I guess we need to use the one from the repositories. # certbot-auto so I guess we need to use the one from the repositories.
- block:
- name: Install certbot (Ubuntu 20.04) - name: Install certbot (Ubuntu 20.04)
apt: name=certbot state=present update_cache=yes apt: name=certbot state=present update_cache=yes
- name: Copy certbot post and pre hooks for nginx
copy: src={{ item.src }} dest={{ item.dest }} owner=root group=root mode=0755
with_items:
- { src: 'stop-nginx.sh', dest: '/etc/letsencrypt/renewal-hooks/post/stop-nginx.sh' }
- { src: 'start-nginx.sh', dest: '/etc/letsencrypt/renewal-hooks/post/start-nginx.sh' }
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('20.04', '==') when: ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('20.04', '==')
tags: letsencrypt tags: letsencrypt