--- # Register The Great Bear's network with the shared Caddy unit. # # Caddy is the base unit (caddy/playbook.yml in the ansible-playbooks repo) and # knows nothing about its upstreams. A service adds itself by writing two files # into the Quadlet directory: # # 1. its own greatbear.network unit, and # 2. a drop-in next to caddy.container that pulls that network into Caddy. # # This mirrors ansible-playbooks/caddy/roles/register/tasks/main.yaml, vendored # so this repo's deploy.sh stands on its own. Keep the bytes in sync with it. # # Included from playbook.yml's pre_tasks, before the app unit is generated. Runs # as the connection user, which must be {{ podman_user }}. - name: Ensure the Quadlet directory exists ansible.builtin.file: path: "{{ quadlet_dir }}" state: directory owner: "{{ podman_user }}" group: "{{ podman_user }}" mode: '0755' - name: "Create the {{ network_name }} network unit" ansible.builtin.copy: dest: "{{ quadlet_dir }}/{{ network_name }}.network" owner: "{{ podman_user }}" group: "{{ podman_user }}" mode: '0644' content: | # {{ network_name }} — logical app network. # Managed by Ansible. Do not edit by hand. # # NetworkName pins the Podman network name. Without it Quadlet would # create "systemd-{{ network_name }}". # # isolate blocks traffic between separate Podman networks, so a container # on this network cannot reach one that is only on another. Caddy still # reaches it, because it is a member of it. [Network] NetworkName={{ network_name }}_net Options=isolate=true notify: Restart Caddy - name: Ensure the Caddy Quadlet drop-in directory exists ansible.builtin.file: path: "{{ quadlet_dir }}/{{ caddy_name }}.container.d" state: directory owner: "{{ podman_user }}" group: "{{ podman_user }}" mode: '0755' - name: "Register {{ network_name }} with Caddy" ansible.builtin.copy: dest: "{{ quadlet_dir }}/{{ caddy_name }}.container.d/50-{{ network_name }}.conf" owner: "{{ podman_user }}" group: "{{ podman_user }}" mode: '0644' content: | # Added by The Great Bear's playbook. Do not edit by hand. # # Quadlet merges this into caddy.container. Deleting this file removes # the network from Caddy on the next daemon-reload. [Container] Network={{ network_name }}.network notify: Restart Caddy