Infrastructure/ansible/tasks/create_vhost.yml

25 lines
773 B
YAML
Raw Normal View History

2024-02-17 11:00:06 +02:00
---
- 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:
2024-02-18 09:52:10 +02:00
src: "{{ template_file | default('vhost.caddy.j2') }}"
2024-02-17 11:00:06 +02:00
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