blob: 619ab038871614da1cef86ab292afe2477629a3c [file] [log] [blame]
Hyunsun Moone4848342020-02-16 04:28:55 -08001# Copyright 2020-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15---
16
17- name: Install dependencies for Docker
18 apt:
Hyunsun Moon6c6db952020-03-04 20:50:51 -080019 name: "{{ item }}"
20 state: present
21 with_items:
Hyunsun Moone4848342020-02-16 04:28:55 -080022 - apt-transport-https
23 - ca-certificates
24 - curl
25 - software-properties-common
Hyunsun Moone4848342020-02-16 04:28:55 -080026 tags: docker
27
28- name: Add Docker GPG key
Hyunsun Moon6c6db952020-03-04 20:50:51 -080029 apt_key:
30 url: https://download.docker.com/linux/ubuntu/gpg
31 state: present
Hyunsun Moone4848342020-02-16 04:28:55 -080032 tags: docker
33
34- name: Add Docker repository
Hyunsun Moon6c6db952020-03-04 20:50:51 -080035 apt_repository:
36 repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable
37 update_cache: yes
38 state: present
Hyunsun Moone4848342020-02-16 04:28:55 -080039 tags: docker
40
41- name: Install Docker CE
42 apt:
43 name: docker-ce={{ docker_version }}
44 state: present
45 update_cache: yes
46 tags: docker
47
48- name: Add current user to "docker" group
49 user:
50 name: "{{ ansible_user }}"
Hyunsun Moon6c6db952020-03-04 20:50:51 -080051 groups:
52 - docker
Hyunsun Moone4848342020-02-16 04:28:55 -080053 append: true
54 tags: docker
55
56- name: Configure Docker daemon options
57 copy:
58 dest: /etc/docker/daemon.json
59 content: "{{ docker_daemon_options | to_json }}"
60 register: docker_register_options
61 notify: restart docker
62 tags: docker
63
64- name: Reload systemd daemon
65 systemd:
66 daemon_reload: true
67 when: docker_register_options is changed
68 tags: docker