summaryrefslogtreecommitdiff
path: root/roles/docker/tasks/main.yaml
blob: 2253f1ed3c43e18bcfc3d9c6625e361b8cf2a2f0 (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
---
- name: prepare /var/lib/docker as LVM
  when: docker_lvm is defined
  block:

  - name: create logical volume
    lvol:
      vg: "{{ docker_lvm.vg }}"
      lv: "{{ docker_lvm.lv }}"
      size: "{{ docker_lvm.size }}"

  - name: create filesystem
    filesystem:
      fstype: "{{ docker_lvm.fs }}"
      dev: "/dev/mapper/{{ docker_lvm.vg | replace('-', '--') }}-{{ docker_lvm.lv | replace('-', '--') }}"

  - name: mount filesytem
    mount:
      src: "/dev/mapper/{{ docker_lvm.vg | replace('-', '--') }}-{{ docker_lvm.lv | replace('-', '--') }}"
      path: /var/lib/docker
      fstype: "{{ docker_lvm.fs }}"
      state: mounted

- name: install apt https transport
  apt:
    name: apt-transport-https
    state: present

- name: add docker apt key
  apt_key:
    data: "{{ lookup('file', 'docker-apt-key.asc') }}"
    state: present

- name: add docker apt repo
  apt_repository:
    repo: "deb https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable"
    state: present
    filename: docker

- name: install docker
  apt:
    name: "docker-ce{% if docker_pkg_version is defined %}={{ docker_pkg_version }}{% endif %}"
    state: present
    force: yes

- name: disable automatic upgrades for docker package
  when: docker_pkg_version is defined
  dpkg_selections:
    name: docker-ce
    selection: hold