--- - name: Check matrix directory exist ansible.builtin.file: path: matrix state: directory - name: Copy matrix conf ansible.builtin.copy: backup: true src: . dest: matrix/ register: matrix_copy_files_results - name: Copy template conf ansible.builtin.template: backup: true src: "{{ item.src }}" dest: "matrix/{{ item.dest }}" loop: - { src: 'docker-compose.yml.j2', dest: 'docker-compose.yml' } register: matrix_copy_templates_results - name: Update and restart container community.docker.docker_compose: project_src: matrix state: present pull: true restarted: "{{ matrix_copy_files_results.changed or matrix_copy_templates_results.changed }}" become: true