You can use the docker_container module in your Ansible playbook. This module has an argument to check the health of a container. You can see the below playbook.
- name: Start container with healthstatus
# Check if nginx server is healthy by curl'ing the server.
# If this fails or timeouts, the healthcheck fails.
test: ["CMD", "curl", "--fail", "http://nginx.host.com"]