Infrastructure/ansible/tasks/create_vhost.yml

26 lines
788 B
YAML

---
- name: Check params
ansible.builtin.assert:
that:
- 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: "{{ template_file | default('vhost.caddy.j2') }}"
dest: "/etc/caddy/sites-available/{{ app_name }}.caddy"
mode: "644"
- 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