Add faas to ansible

This commit is contained in:
Tobias Reisinger 2023-12-10 23:49:02 +01:00
parent 063b422426
commit 2a3fe723ab
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
13 changed files with 84 additions and 52 deletions
_ansible/templates

View file

@ -1,8 +1,39 @@
{%- macro caddy_site_hsts(svc, for_www) -%}
{%- if svc.hsts|default(false) and (svc.www_domain|default(false) == for_www) -%}
{{ 'header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload"' if svc.hsts|default(false) }}
{%- endif -%}
{%- endmacro -%}
{% macro caddy_site(svc) %}
{%- for domain in svc.additional_domains|default([]) %}
{{ domain }},
{% endfor -%}
{{ "www." + svc.domain if svc.www_domain|default(false) else svc.domain }} {
import default
{{ caddy_site_hsts(svc, false) }}
{{ svc.caddy_extra | indent(width='\t', first=True) if svc.caddy_extra|default(false) }}
handle {
{% if svc.faas_function|default(false) %}
import faas {{ svc.faas_function }}
{% else %}
reverse_proxy {{ svc.docker_host|default(svc.name) }}:{{ svc.port }}
{% endif %}
}
}
{% if svc.www_domain|default(false) %}
{{ svc.domain }} {
import default
{{ svc.caddy_extra | default('') | indent(width='\t', first=True) }}
reverse_proxy {{ svc.name }}:{{ svc.port }}
{{ caddy_site_hsts(svc, true) }}
redir https://www.{{ svc.domain }}{uri}
}
{% endif %}
{% endmacro -%}
{{ caddy_site(svc) }}
{%- for extra_svc in svc.extra_svcs %}
{{ caddy_site(extra_svc) }}
{% endfor %}