--- - name: Copy the Dockerfile ansible.builtin.copy: src: Dockerfile dest: "{{ (service_path, 'Dockerfile') | path_join }}" mode: "0644" register: cmd_result - name: Set the docker rebuild flag ansible.builtin.set_fact: docker_rebuild: true when: cmd_result.changed # noqa: no-handler We need to handle the restart per service. Handlers don't support variables.