
# Copyright 2017-present Open Networking Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


---

- name: Trust docker apt key
  apt_key:
    data={{ lookup('file', 'docker_apt_key.gpg') }}

- name: Debian add Docker repository and update apt cache
  apt_repository:
    repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
    update_cache: yes
    state: present
  tags: [docker]

- name: Install docker-ce using apt
  apt:
    name: docker-ce=17.06.*
    force: yes
  tags: [docker, skip_ansible_lint]

- name: Debian python-pip is present
  apt: name=python-pip state=present
  tags: [docker]

- name: docker python package present
  pip:
    name: "docker>=2.4.2"
    state: present
  tags: [docker]

- name: Debian files are present
  template:
    src: "{{ docker_cfg }}"
    dest: "{{ docker_cfg_dest }}"
  tags: [docker]
  notify:
    - docker-restart

- name: vagrant user is added to the docker group
  user:
    name: "{{ ansible_env['SUDO_USER'] }}"
    group: docker
  tags: [docker]
  notify:
    - docker-restart
