- name: Find existing caddy site configs ansible.builtin.find: paths: "{{ caddy_config_path }}" recurse: false register: find_result - name: Map exisiting/wanted caddy site configs ansible.builtin.set_fact: caddy_site_configs_have: "{{ find_result.files | map(attribute='path') }}" caddy_site_configs_want: "{{ host_services | services_names() | list_prefix_path_suffix(caddy_config_path, '.conf') }}" - name: Remove unwanted caddy site configs ansible.builtin.file: path: "{{ item }}" state: absent loop: "{{ caddy_site_configs_have | difference(caddy_site_configs_want) }}" become: true - name: Reload caddy container ansible.builtin.command: cmd: docker compose exec app sh -c "caddy validate --config /etc/caddy/Caddyfile && caddy reload --config /etc/caddy/Caddyfile" chdir: "{{ caddy_path }}" when: "'local-dev' != inventory_hostname" changed_when: true