Infrastructure/ansible/tasks/create_vhost.yml

28 lines
827 B
YAML
Raw Normal View History

2024-02-17 11:00:06 +02:00
---
- name: Check params
ansible.builtin.assert:
that:
- app_name is defined
- external_url is defined
- proxy_url is defined
- not(tls.type == "cloudflare" and tls.cloudflare_token is undefined)
- not(tls.type == "file" and (tls.cert is undefined or tls.key is undefined))
- tls.type is not defined or (tls.type in ['auto', 'internal', 'cloudflare', 'file'] )
- name: Set up Caddy
ansible.builtin.include_role:
name: reverse-proxy
- name: Template vhost file
ansible.builtin.template:
src: vhost.caddy.j2
dest: "/etc/caddy/sites-available/{{ app_name }}.caddy"
- name: Symlink vhost
ansible.builtin.file:
src: "/etc/caddy/sites-available/{{ app_name }}.caddy"
dest: "/etc/caddy/sites-enabled/{{ app_name }}.caddy"
state: link
notify: Reload Caddy