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