---
# With work from https://github.com/lexrus/ansible-role-docker/blob/master/tasks/main.yml
- hosts: all
  become: yes
  become_user: root
  tasks:
    - name: Ensure that APT works with the https method
      apt: name={{ item }} state=present
      with_items:
        - apt-transport-https
        - ca-certificates

    - name: Install docker GPG key
      apt_key: keyserver=hkp://p80.pool.sks-keyservers.net:80 id=58118E89F3A912897C070ADBF76221572C52609D state=present

    - name: Add docker apt repository
      apt_repository: repo="deb https://apt.dockerproject.org/repo {{ ansible_distribution|lower }}-{{ ansible_lsb.codename }} main" state=present
      register: result

    - name: Update apt-cache
      apt: update_cache=yes
      when: result.changed

    - name: Install docker package
      apt: name=docker-engine state=present

Add a docker installation playbook for Debian
Add a docker installation playbook for Debian
