Add a vhost role

This commit is contained in:
uumas
2022-11-18 05:38:17 +02:00
parent 1340b825e1
commit 3974e6eb46
8 changed files with 143 additions and 1 deletions

View File

@@ -0,0 +1,25 @@
---
- name: Add caddy vhost config
blockinfile:
path: /etc/caddy/Caddyfile
marker: "# {mark} ANSIBLE MANAGED BLOCK {{ vhost_id }}"
block: |
{{ vhost_domains | join(' ') }} {
{% if vhost_type == 'reverse_proxy' %}
reverse_proxy {{ proxy_target_protocol }}://{{ proxy_target_host }}:{{ proxy_target_port }} {
{% if proxy_target_protocol == 'https' and proxy_target_host == 'localhost' %}
transport http {
tls_insecure_skip_verify
}
{% endif %}
}
{% endif %}
{% if vhost_type == 'redirect' %}
redir {{ redirect_target }} {{ redirect_type }}
{% endif %}
}
validate: 'caddy validate --config %s --adapter caddyfile'
backup: true
notify: reload caddy