diff options
Diffstat (limited to 'roles/docker')
-rw-r--r-- | roles/docker/defaults/main.yml | 2 | ||||
-rw-r--r-- | roles/docker/tasks/configure.yml | 30 | ||||
-rw-r--r-- | roles/docker/tasks/storage.yml | 3 |
3 files changed, 30 insertions, 5 deletions
diff --git a/roles/docker/defaults/main.yml b/roles/docker/defaults/main.yml index def846d..5189a8e 100644 --- a/roles/docker/defaults/main.yml +++ b/roles/docker/defaults/main.yml @@ -2,6 +2,8 @@ docker_exclude_vgs: "{{ ands_data_vg is defined | ternary( [ ands_data_vg ], [] docker_lv: "docker-pool" docker_root_lv: "docker-root-lv" docker_setup_root: "{{ docker_root_volume_size is defined }}" +docker_reconfigure: false + docker_min_size: 100 docker_max_log_size: "2m" diff --git a/roles/docker/tasks/configure.yml b/roles/docker/tasks/configure.yml index 5d29291..fa31b1d 100644 --- a/roles/docker/tasks/configure.yml +++ b/roles/docker/tasks/configure.yml @@ -4,10 +4,13 @@ # with_items: [ docker, docker-client, docker-common ] - name: install docker + register: docker_install_result include_tasks: install.yml - name: start docker + register: docker_start_result service: name="docker" state="started" + when: not docker_reconfigure - name: Configure bridge-nf-call-iptables with sysctl sysctl: name="net.bridge.bridge-nf-call-iptables" value=1 state=present sysctl_set=yes @@ -20,17 +23,34 @@ register: loop_device_check failed_when: false changed_when: loop_device_check.rc == 0 + when: not docker_reconfigure -- set_fact: docker_reinit="{{ (loop_device_check.rc == 0) or (vg == '') or (docker_setup_root and ((root_vg == '') or (vg != root_vg))) or (docker_storage_vg is defined and (docker_storage_vg != vg)) }}" +- set_fact: docker_reinit=false + +- set_fact: docker_reinit=true vars: + check: "{{ loop_device_check | default({}) }}" + lv: "{{ ansible_lvm['lvs'][docker_lv] | default({}) }}" + vg: "{{ lv['vg'] | default('') }}" + when: + - docker_install_result | changed + - docker_start_result | changed + - ansible_lvm['lvs'][docker_lv] is not defined + +# Pass option docker_reconfigure to run this... +- set_fact: docker_reinit="{{ loop_back or wrong_root_vg or wrong_docker_vg }}" + vars: + check: "{{ loop_device_check | default({}) }}" lv: "{{ ansible_lvm['lvs'][docker_lv] | default({}) }}" vg: "{{ lv['vg'] | default('') }}" root_lv: "{{ ansible_lvm['lvs'][docker_root_lv] | default({}) }}" root_vg: "{{ root_lv['vg'] | default('') }}" - -- debug: msg="Re-initializing - {{ docker_reinit }}, Loopback check - {{ loop_device_check.stderr }}" - when: loop_device_check.stderr - + loop_back: "{{ check.rc | default(9) == 0 }}" + wrong_root_vg: "{{ docker_setup_root and ((root_vg == '') or (vg != root_vg)) }}" + wrong_docker_vg: "{{ docker_storage_vg is defined and (docker_storage_vg != vg) }}" + when: + - docker_reconfigure | default(false) + - import_tasks: storage.yml when: docker_reinit diff --git a/roles/docker/tasks/storage.yml b/roles/docker/tasks/storage.yml index e431030..d6d531a 100644 --- a/roles/docker/tasks/storage.yml +++ b/roles/docker/tasks/storage.yml @@ -29,6 +29,9 @@ - name: stop docker service: name="docker" state="stopped" +- name: unmount /var/lib/docker + mount: path="/var/lib/docker" state="unmounted" + - name: delete /var/lib/docker file: path="/var/lib/docker" state=absent |