---
- name: Remove any previous versions of Docker
  package:
    name:
      - docker
      - docker-engine
    state: absent
    
- name: Add Docker gpg key to apt
  apt_key:
    url: https://download.docker.com/linux/ubuntu/gpg
    id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88
    state: present
  register: add_repository_key
  
- name: Add Docker repository to apt
  apt_repository:
    repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
    state: present
    update_cache: true
    
- name: Install Docker
  package:
    name: docker-ce
    state: present
  notify: restart docker

- name: Install python-pip package
  package:
    name: python-pip
    state: latest

- name: Install Docker python packages
  pip:
    name: docker
    name: docker-compose