--- - name: Check matrix directory exist ansible.builtin.file: path: matrix state: directory - name: Copy matrix conf ansible.builtin.copy: src: . dest: matrix/ register: matrix_copy_files_results - name: Copy template conf ansible.builtin.template: src: "{{ item.src }}" dest: "matrix/{{ item.dest }}" loop: - { src: 'docker-compose.yml', dest: 'docker-compose.yml' } - name: Update and restart container community.docker.docker_compose_v2: project_src: matrix state: present pull: always recreate: "{{ 'always' if matrix_copy_files_results.changed else 'auto' }}" become: true