---
- name: 'Install apt-transport-https'
  apt:
    name: 'apt-transport-https'

- name: 'Add the docker apt signing key'
  apt_key:
    keyserver: 'pool.sks-keyservers.net'
    id: '58118E89F3A912897C070ADBF76221572C52609D'
  notify: 'docker-apt-get-update'

- name: 'Add the official docker repo'
  apt_repository:
    repo: 'deb https://apt.dockerproject.org/repo ubuntu-{{ ansible_distribution_release }} main'
    state: 'present'
  notify: 'docker-apt-get-update'

- meta: flush_handlers

- name: 'Install docker'
  apt:
    name: 'docker-engine'
    state: 'latest'

- name: 'Start the docker service'
  service:
    name: 'docker'
    state: 'started'
    enabled: 'yes'

- name: 'Ensure that the docker service is functional'
  docker_ping:
  register: result
  retries: 5
  delay: 10
  until: result|success

- name: 'Install python-pip'
  apt:
    name: 'python-pip'
    state: 'present'

- name: 'Install virtualenv'
  pip:
    name: 'virtualenv'
    state: 'present'

- name: 'Install docker-py'
  pip:
    name: 'docker-py'
    state: 'present'

---
- name: 'Install apt-transport-https'
  apt:
    name: 'apt-transport-https'

- name: 'Add the docker apt signing key'
  apt_key:
    keyserver: 'pool.sks-keyservers.net'
    id: '58118E89F3A912897C070ADBF76221572C52609D'
  notify: 'docker-apt-get-update'

- name: 'Add the official docker repo'
  apt_repository:
    repo: 'deb https://apt.dockerproject.org/repo {{ansible_distribution|lower}}-{{ ansible_distribution_release }} main'
    state: 'present'
  notify: 'docker-apt-get-update'

- meta: flush_handlers

- name: 'Install docker'
  apt:
    name: 'docker-engine'
    state: 'latest'

- name: 'Start the docker service'
  service:
    name: 'docker'
    state: 'started'
    enabled: 'yes'

- name: 'Ensure that the docker service is functional'
  docker_ping:
  register: result
  retries: 5
  delay: 10
  until: result|success

- name: 'Install python-pip'
  apt:
    name: 'python-pip'
    state: 'present'

- name: 'Install virtualenv'
  pip:
    name: 'virtualenv'
    state: 'present'

- name: 'Install docker-py'
  pip:
    name: 'docker-py'
    state: 'present'

Support for debian without breaking ubuntu
Support for debian without breaking ubuntu
