correct use of default with variable

This commit is contained in:
rene
2022-03-18 18:53:30 +01:00
parent 18f0ce341c
commit 50dd2691d5
3 changed files with 6 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
--- ---
- stat: path=/etc/letsencrypt/live/{{ mastodon_host | default('{{ ansible_fqdn }}') }}/fullchain.pem - stat: path=/etc/letsencrypt/live/{{ mastodon_host | default(ansible_fqdn) }}/fullchain.pem
register: letsencrypt_cert register: letsencrypt_cert
- name: Copy letsencrypt nginx config - name: Copy letsencrypt nginx config
@@ -17,7 +17,7 @@
command: "systemctl reload nginx" command: "systemctl reload nginx"
- name: Install letsencrypt cert - name: Install letsencrypt cert
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 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 when: not letsencrypt_cert.stat.exists
- name: Letsencrypt Job - name: Letsencrypt Job

View File

@@ -1,6 +1,6 @@
--- ---
- debug: - debug:
msg: "Hostname: {{ mastodon_host | default({{ ansible_fqdn }}) }}" msg: "Hostname: {{ mastodon_host | default(ansible_fqdn) }}"
- name: mastodon | Copy nginx config - name: mastodon | Copy nginx config
template: template:

View File

@@ -6,7 +6,7 @@ map $http_upgrade $connection_upgrade {
server { server {
listen 80; listen 80;
listen [::]:80; listen [::]:80;
server_name {{ mastodon_host | default('{{ ansible_fqdn }}') }}; server_name {{ mastodon_host | default(ansible_fqdn') }};
# Useful for Let's Encrypt # Useful for Let's Encrypt
location /.well-known/acme-challenge/ { allow all; } location /.well-known/acme-challenge/ { allow all; }
@@ -24,8 +24,8 @@ server {
ssl_session_cache shared:SSL:10m; ssl_session_cache shared:SSL:10m;
{% if disable_letsencrypt != "true" %} {% if disable_letsencrypt != "true" %}
ssl_certificate /etc/letsencrypt/live/{{ mastodon_host | default('{{ ansible_fqdn }}') }}/fullchain.pem; ssl_certificate /etc/letsencrypt/live/{{ mastodon_host | default(ansible_fqdn) }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{{ mastodon_host | default('{{ ansible_fqdn }}') }}/privkey.pem; ssl_certificate_key /etc/letsencrypt/live/{{ mastodon_host | default(ansible_fqdn) }}/privkey.pem;
{% endif %} {% endif %}
keepalive_timeout 70; keepalive_timeout 70;