---
- name: Caddy reverse proxy
  hosts: ulna

  tasks:
    - name: Ensure Caddy is installed
      ansible.builtin.apt:
        name: caddy
        state: present
      become: true

    - name: Reverse proxies for ulna
      when: inventory_hostname in groups['ulna']
      ansible.builtin.template:
        src: templates/Caddyfile.ulna.j2
        dest: /etc/caddy/Caddyfile
      become: true

    - name: Restart caddy
      ansible.builtin.systemd:
        state: restarted
        name: caddy
      become: true
