diff options
Diffstat (limited to 'roles/docker/tasks/storage.yml')
-rw-r--r-- | roles/docker/tasks/storage.yml | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/roles/docker/tasks/storage.yml b/roles/docker/tasks/storage.yml index 5a5c858..e431030 100644 --- a/roles/docker/tasks/storage.yml +++ b/roles/docker/tasks/storage.yml @@ -1,11 +1,13 @@ --- +# 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_volume_size | default(docker_min_size)) + - (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) @@ -13,11 +15,13 @@ - fail: msg="Can't detect Docker VG" when: not docker_storage_vg is defined -- name: check to see if {{ docker_storage_device }} exists +- 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 }} AUTO_EXTEND_POOL=true" +- 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 ) @@ -28,6 +32,29 @@ - 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 }}" @@ -38,4 +65,3 @@ - name: docker storage setup command: docker-storage-setup - |