---
- name: Start docker container for development environment
  docker:
    name: docker-dev-env     # use named container for idempotency
    image: phusion/baseimage
    privileged: True
    state: running
    command: "/sbin/my_init --enable-insecure-key"

- name: Add docker IPs to host group
  add_host: hostname={{ item.NetworkSettings.IPAddress }} groupname=docker-dev
  with_items: docker_containers

---
- name: Start docker container for development environment
  docker:
    name: docker-dev-env     # use named container for idempotency
    image: phusion/baseimage
    privileged: True
    state: running
    command: "/sbin/my_init --enable-insecure-key"

- name: Add docker IPs to host group
  add_host: hostname={{ item.NetworkSettings.IPAddress }} groupname=docker-dev
  with_items: docker_containers

- name: Wait until we can ssh in to the new container(s)
  command: ssh root@{{ item.NetworkSettings.IPAddress }} /bin/echo UP
  register: connections
  until: connections.stdout == "UP"
  retries: 10
  delay: 1
  with_items: docker_containers

Add delay check loop to ensure container is accessible by ssh before continuing
Add delay check loop to ensure container is accessible by ssh before continuing
