---

- name: Install prerrequisites
  apt:
    name: "{{item}}"
    state: latest
  with_items:
    - linux-image-generic
    - linux-image-extra-{{ansible_kernel}}
    - linux-image-extra-virtual

- name: Setup repo sources
  apt_repository:
    filename: docker
    repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
    state: present

- name: Setup apt key
  apt_key:
    url: https://download.docker.com/linux/ubuntu/gpg
    state: present

- name: Install
  apt:
    name: docker-ce
    state: latest

- name: Startup
  service:
    name: docker
    state: started

- name: Add group
  group:
    name: docker
    state: present

- name: Configure for non-root usage (requires manual re-login)
  user:
    name: "{{lookup('env', 'USER')}}"
    groups: docker
    append: yes

- name: Detect docker-compose version
  shell: "docker-compose --version | awk -F'[ ,]' '{ print $3 }'"
  register: compose

- name: Download docker-compose
  get_url:
    url: "{{compose_url}}"
    force: yes
    dest: /usr/local/bin/docker-compose
    mode: 0755
  when: compose.stdout != compose_version

---

- name: Setup repo sources
  apt_repository:
    filename: docker
    repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
    state: present

- name: Setup apt key
  apt_key:
    url: https://download.docker.com/linux/ubuntu/gpg
    state: present

- name: Install
  apt:
    name: docker-ce
    state: latest

- name: Startup
  service:
    name: docker
    state: started

- name: Add group
  group:
    name: docker
    state: present

- name: Configure for non-root usage (requires manual re-login)
  user:
    name: "{{lookup('env', 'USER')}}"
    groups: docker
    append: yes

- name: Detect docker-compose version
  shell: "docker-compose --version | awk -F'[ ,]' '{ print $3 }'"
  register: compose

- name: Download docker-compose
  get_url:
    url: "{{compose_url}}"
    force: yes
    dest: /usr/local/bin/docker-compose
    mode: 0755
  when: compose.stdout != compose_version

Remove dependencies no longer needed on xenial
Remove dependencies no longer needed on xenial
