summaryrefslogtreecommitdiffstats
path: root/roles/docker/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'roles/docker/tasks')
-rw-r--r--roles/docker/tasks/configure.yml30
-rw-r--r--roles/docker/tasks/storage.yml3
2 files changed, 28 insertions, 5 deletions
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