blob: 7d90bbbcaf7ede71b675ea1d88aad368258cb4fd [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:
19 name:
20 - apt-transport-https
21 - ca-certificates
22 - curl
23 - software-properties-common
24 state: present
25 tags: docker
26
27- name: Add Docker GPG key
28 shell: |
29 curl -sSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
30 args:
31 warn: false
32 tags: docker
33
34- name: Add Docker repository
35 shell: |
36 add-apt-repository \
37 "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
38 $(lsb_release -cs) \
39 stable"
40 args:
41 warn: false
42 tags: docker
43
44- name: Install Docker CE
45 apt:
46 name: docker-ce={{ docker_version }}
47 state: present
48 update_cache: yes
49 tags: docker
50
51- name: Add current user to "docker" group
52 user:
53 name: "{{ ansible_user }}"
54 groups: docker
55 append: true
56 tags: docker
57
58- name: Configure Docker daemon options
59 copy:
60 dest: /etc/docker/daemon.json
61 content: "{{ docker_daemon_options | to_json }}"
62 register: docker_register_options
63 notify: restart docker
64 tags: docker
65
66- name: Reload systemd daemon
67 systemd:
68 daemon_reload: true
69 when: docker_register_options is changed
70 tags: docker