---
- name: Ensure old versions of Docker are not installed.
  package:
    name:
      - docker
      - docker-engine
    state: absent

- name: Ensure dependencies are installed.
  apt:
    name:
      - apt-transport-https
      - ca-certificates
      - gnupg2
      - curl
    state: present
  become: yes

- name: Add Docker apt key
  shell: >
    curl -sSL {{ docker_apt_gpg_key }} | sudo apt-key add -
  args:
    warn: false
  become: yes

- name: Add Docker repository.
  apt_repository:
    repo: "{{ docker_apt_repository }}"
    state: present
    update_cache: true
  become: yes
