blob: e43103041859de21bcf126de420f2f79f1d9e224 (
plain)
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
|
---
# We need to adjust docker_min_size if docker_volume_size set (min_size is just given in GB, but volume size
# support suffixes and we need to handle this).
- name: list volume groups
set_fact: available_vg="{{ item.key }}"
with_dict: "{{ ansible_lvm.vgs }}"
when:
- not available_vg is defined
- not item.key in ( docker_exclude_vgs | default([]) )
- (item.value.free_g | int) > docker_min_size
- set_fact: docker_storage_vg="{{ available_vg }}"
when: (not docker_storage_vg is defined) and (available_vg is defined)
- fail: msg="Can't detect Docker VG"
when: not docker_storage_vg is defined
- name: "check to see if {{ docker_storage_device }} exists"
command: "test -e {{ docker_storage_device }}"
when: docker_storage_device is defined
- set_fact: docker_storage_config="VG={{ docker_storage_vg }} DATA_SIZE={{ docker_volume_size | default(docker_min_size ~ 'G') }} AUTO_EXTEND_POOL=true"
- set_fact: docker_storage_config="{{ docker_storage_config }} DOCKER_ROOT_VOLUME=yes DOCKER_ROOT_VOLUME_SIZE={{ docker_root_volume_size | default(docker_min_size ~ 'G') }}"
when: docker_setup_root
- set_fact: docker_storage_config="{{ docker_storage_config }} DEVS={{ docker_storage_device }}"
when: ( docker_storage_device is defined ) and ( ansible_lvm.vgs[docker_storage_vg] is not defined )
- name: stop docker
service: name="docker" state="stopped"
- name: delete /var/lib/docker
file: path="/var/lib/docker" state=absent
- name: "delete {{ docker_lv }} lv"
lvol: vg="{{ ansible_lvm['lvs'][docker_lv]['vg'] }}" lv="{{ docker_lv }}" state="absent" force="yes"
when: ansible_lvm['lvs'][docker_lv] is defined
- name: delete docker-pool lv
lvol: vg="{{ ansible_lvm['lvs']['docker-pool']['vg'] }}" lv="docker-pool" state="absent" force="yes"
when: ansible_lvm['lvs']['docker-pool'] is defined
- name: unmount docker partition
mount: path="/var/lib/docker" state="unmounted"
- name: "delete {{ docker_root_lv }} lv"
lvol: vg="{{ ansible_lvm['lvs'][docker_root_lv]['vg'] }}" lv="{{ docker_root_lv }}" state="absent" force="yes"
when: ansible_lvm['lvs'][docker_root_lv] is defined
- name: delete docker-pool lv
lvol: vg="{{ ansible_lvm['lvs']['docker-root-lv']['vg'] }}" lv="docker-root-lv" state="absent" force="yes"
when: ansible_lvm['lvs']['docker-root-lv'] is defined
- name: remove old configuration
file: path="/etc/sysconfig/docker-storage" state="absent"
- name: generate docker-storage-setup config file
copy:
content: "{{ docker_storage_config }}"
dest: /etc/sysconfig/docker-storage-setup
owner: root
group: root
mode: 0664
- name: docker storage setup
command: docker-storage-setup
|