--- - name: Build traefik compose dirs ansible.builtin.file: state: directory dest: '{{ traefik_base }}/{{ item.path }}' with_filetree: '../templates' when: item.state == 'directory' - name: Build traefik compose files ansible.builtin.template: src: '{{ item.src }}' dest: '{{ traefik_base }}/{{ item.path }}' with_filetree: '../templates' when: item.state == 'file' - name: Deploy Traefik stack ansible.builtin.command: cmd: "docker stack deploy -c {{ traefik_base }}/stacks/docker-compose.yml traefik"