diff options
Diffstat (limited to 'roles/docker/tasks/storage.yml')
-rw-r--r-- | roles/docker/tasks/storage.yml | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/roles/docker/tasks/storage.yml b/roles/docker/tasks/storage.yml new file mode 100644 index 0000000..595979c --- /dev/null +++ b/roles/docker/tasks/storage.yml @@ -0,0 +1,41 @@ +--- +- 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)) + +- 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 }} AUTO_EXTEND_POOL=true" + +- set_fact: docker_storage_config="{{ docker_storage_config }} DEVS={{ docker_storage_device }}" + when: ( docker_storage_device is defined ) and ( not ansible_lvm.vgs.{{ docker_storage_vg }} is defined ) + +- name: stop docker + service: name="docker" state="stopped" + +- name: delete /var/lib/docker + file: path="/var/lib/docker" 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 + |