From 504fb5e84489636c16c15b00a99b0e6352304dcc Mon Sep 17 00:00:00 2001 From: Dmitry Ilvokhin Date: Sat, 6 Jan 2024 19:02:56 +0000 Subject: Make certificate a role --- roles/certificate/tasks/main.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 roles/certificate/tasks/main.yml (limited to 'roles/certificate/tasks') diff --git a/roles/certificate/tasks/main.yml b/roles/certificate/tasks/main.yml new file mode 100644 index 0000000..0edc725 --- /dev/null +++ b/roles/certificate/tasks/main.yml @@ -0,0 +1,18 @@ +- ansible.builtin.include_role: + name: certbot + +- name: Request SSL certificate from Let's Encrypt + shell: | + # Make task independent: if nginx is already running, stop it and then + # start back on exit. + [ -f /var/run/nginx.pid ] && systemctl stop nginx + trap "systemctl start nginx" EXIT + certbot certonly \ + --standalone \ + --agree-tos \ + --renew-by-default \ + --email webmaster@ilvokhin.com \ + --rsa-key-size 4096 \ + -d {{ domains | join(' -d ') }} + args: + creates: '/etc/letsencrypt/live/{{ domains | first }}/fullchain.pem' -- cgit v1.2.3-70-g09d2