--- # Include this to delete the current test host container. # # In order to recover from test exceptions, this cleanup is expected to # be done in an "always:" task on the same block as the test task(s). So # it happens in a task "on" the host being tested. In order to delete the # host's container, the task uses its own hostname (which is same as the # container name) but delegates the docker action to localhost. - block: # so handlers don't break the test by trying to run after teardown: - meta: flush_handlers always: - name: delete test container delegate_to: localhost connection: local docker_container: name: "{{ inventory_hostname }}" state: absent failed_when: False