blob: cf879631172f4c7f26590ca5a3c8be98a7f5c782 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
---
- name: install docker daemon config
when: docker_daemon_config is defined
block:
- name: create docker config directory
file:
name: /etc/docker
state: directory
mode: 0700
- name: write docker daemon config
copy:
content: "{{ docker_daemon_config | to_nice_json }}\n"
dest: /etc/docker/daemon.json
notify: restart docker
- name: prepare storage volume for /var/lib/docker
when: docker_storage is defined
vars:
storage_volume: "{{ docker_storage | combine({'dest': '/var/lib/docker'}) }}"
include_role:
name: "storage/{{ docker_storage.type }}/volume"
- name: prepare package provider
when: docker_pkg_provider != 'distro'
include_role:
name: "apt-repo/{{ docker_pkg_provider }}"
- name: generate apt pin file for docker package
when: docker_pkg_version is defined
copy:
dest: "/etc/apt/preferences.d/{{ docker_pkg_name }}.pref"
content: |
Package: {{ docker_pkg_name }}
Pin: version {{ docker_pkg_version }}
Pin-Priority: 1001
- name: remove apt pin file for docker package
when: docker_pkg_version is not defined
file:
path: "/etc/apt/preferences.d/{{ docker_pkg_name }}.pref"
state: absent
- name: install docker
apt:
name:
- "{{ docker_pkg_name }}{% if docker_pkg_version is defined %}={{ docker_pkg_version }}{% endif %}"
- "{{ python_basename }}-docker"
state: present
allow_downgrade: yes
- name: install docker plugin
when: (docker_plugins | length) > 0
apt:
name: "{{ docker_plugins | map('extract', docker_plugin_pkg_names) | list }}"
state: present
## TODO: for now this is only needed on Debian Bullseye and beyond
- name: install apparmor
when:
- ansible_distribution == 'Debian' and (ansible_distribution_major_version | int) >= 11
apt:
name: apparmor
state: present
- name: start and enable docker
service:
name: docker
enabled: true
state: started
|