--- - name: Create Caddyfile copy: src: "{{ caddy_config_file }}" dest: "/etc/caddy/Caddyfile" owner: "caddy" mode: 0640 notify: - Reload caddy - name: Clear sites.d directory before adding net configurations file: path: "{{ caddy_config_sites_directory }}" owner: "caddy" group: "caddy" state: absent when: caddy_config_sites_paths is defined and caddy_config_sites_clear - name: Add sites.d directory file: path: "{{ caddy_config_sites_directory }}" owner: "caddy" group: "caddy" state: directory when: caddy_config_sites_paths is defined - name: Template site configurations template: src: "{{ item }}" dest: "{{ caddy_config_sites_directory }}" owner: "caddy" group: "caddy" with_fileglob: "{{ caddy_config_sites_paths }}" when: caddy_config_sites_paths is defined notify: - Reload caddy