--- - name: test docker setup become: true community.docker.docker_container: state: started name: hello-world image: hello-world register: docker_test when: docker_install is changed - name: remove test container become: true community.docker.docker_container: state: absent name: hello-world image: hello-world when: docker_test is changed