From 1dce266e8d38dceb1357d6008a3bed67e8efcd19 Mon Sep 17 00:00:00 2001 From: rene Date: Wed, 16 Mar 2022 16:53:45 +0100 Subject: [PATCH] copy nginx config nevertheles if cert is present --- roles/mastodon/tasks/system_setup/letsencrypt.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/roles/mastodon/tasks/system_setup/letsencrypt.yml b/roles/mastodon/tasks/system_setup/letsencrypt.yml index 6a3444b..9de2003 100644 --- a/roles/mastodon/tasks/system_setup/letsencrypt.yml +++ b/roles/mastodon/tasks/system_setup/letsencrypt.yml @@ -1,25 +1,23 @@ --- -- stat: path=/etc/letsencrypt/live/{{ mastodon_host }}/fullchain.pem +- stat: path=/etc/letsencrypt/live/{{ mastodon_host | default({{ ansible_fqdn }}) }}/fullchain.pem register: letsencrypt_cert - name: Copy letsencrypt nginx config template: src: ../files/nginx/letsencrypt.conf.j2 dest: /etc/nginx/sites-available/mastodon.conf - when: not letsencrypt_cert.stat.exists - name: Symlink enabled site file: src: "/etc/nginx/sites-available/mastodon.conf" dest: "/etc/nginx/sites-enabled/mastodon.conf" state: link - when: not letsencrypt_cert.stat.exists - name: Reload nginx command: "systemctl reload nginx" - name: Install letsencrypt cert - command: letsencrypt certonly -n --webroot -d {{ mastodon_host }} -w {{ mastodon_home }}/{{ mastodon_path }}/public/ --email "webmaster@{{ mastodon_host }}" --agree-tos && systemctl reload nginx + command: letsencrypt certonly -n --webroot -d {{ mastodon_host | default({{ ansible_fqdn }}) }} -w {{ mastodon_home }}/{{ mastodon_path }}/public/ --email "webmaster@{{ mastodon_host | default({{ ansible_fqdn }}) }}" --agree-tos && systemctl reload nginx when: not letsencrypt_cert.stat.exists - name: Letsencrypt Job