diff options
-rw-r--r-- | roles/docker_storage/tasks/main.yml | 4 | ||||
-rw-r--r-- | roles/docker_storage_setup/README.md | 42 | ||||
-rw-r--r-- | roles/docker_storage_setup/defaults/main.yml | 2 | ||||
-rwxr-xr-x | roles/docker_storage_setup/tasks/main.yml | 82 |
4 files changed, 128 insertions, 2 deletions
diff --git a/roles/docker_storage/tasks/main.yml b/roles/docker_storage/tasks/main.yml index 48a3fc208..71467d8a8 100644 --- a/roles/docker_storage/tasks/main.yml +++ b/roles/docker_storage/tasks/main.yml @@ -15,7 +15,7 @@ vg: "{{ dst_vg }}" size: 5%VG register: dst_lvol_metadata - + - name: Update docker_storage options lineinfile: @@ -31,7 +31,7 @@ command: systemctl daemon-reload notify: - restart docker - when: dst_config | changed or + when: dst_config | changed or dst_lvg | changed or dst_lvol_data | changed or dst_lvol_metadata | changed diff --git a/roles/docker_storage_setup/README.md b/roles/docker_storage_setup/README.md new file mode 100644 index 000000000..6039b349a --- /dev/null +++ b/roles/docker_storage_setup/README.md @@ -0,0 +1,42 @@ +docker_storage_setup +========= +This role coverts docker to go from loopback to direct-lvm (the Red Hat recommended way to run docker). + +It requires the block device to be already provisioned and attached to the host. + + Notes: + * This is NOT idempotent. Conversion needs to be done for it to be idempotent + * This will remove /var/lib/docker! + * You will need to re-deploy docker images + +Configure docker_storage_setup +------------ + +None + +Role Variables +-------------- + +dss_docker_device: defaults to /dev/xvdb + +Dependencies +------------ + +None + +Example Playbook +---------------- + + - hosts: servers + roles: + - { role/docker_storage_setup, dss_docker_device: '/dev/xvdb' } + +License +------- + +ASL 2.0 + +Author Information +------------------ + +OpenShift operations, Red Hat, Inc diff --git a/roles/docker_storage_setup/defaults/main.yml b/roles/docker_storage_setup/defaults/main.yml new file mode 100644 index 000000000..5013aba97 --- /dev/null +++ b/roles/docker_storage_setup/defaults/main.yml @@ -0,0 +1,2 @@ +--- +dss_docker_device: /dev/xvdb diff --git a/roles/docker_storage_setup/tasks/main.yml b/roles/docker_storage_setup/tasks/main.yml new file mode 100755 index 000000000..1a30ea4cb --- /dev/null +++ b/roles/docker_storage_setup/tasks/main.yml @@ -0,0 +1,82 @@ +--- +- name: Ensure docker is installed + action: "{{ ansible_pkg_mgr }} name={{ item }} state=present" + with_items: + - docker + +- name: start docker + service: + name: docker + state: started + +- name: Determine if loopback + shell: docker info | grep 'Data file:.*loop' + register: loop_device_check + ignore_errors: yes + +- debug: + var: loop_device_check + +- name: fail if we don't detect loopback + fail: + msg: loopback not detected! Please investigate manually. + when: loop_device_check.rc == 1 + +- name: "check to see if {{ dss_docker_device }} exists" + command: "test -e {{ dss_docker_device }}" + register: docker_dev_check + ignore_errors: yes + +- debug: var=docker_dev_check + +- name: "fail if {{ dss_docker_device }} doesn't exist" + fail: + msg: "{{ dss_docker_device }} doesn't exist. Please investigate" + when: docker_dev_check.rc != 0 + +- name: stop docker + service: + name: docker + state: stopped + +- name: delete /var/lib/docker + command: rm -rf /var/lib/docker + +- name: remove /var/lib/docker + command: rm -rf /var/lib/docker + +- name: copy the docker-storage-setup config file + copy: + content: > + DEVS={{ dss_docker_device }}\n + VG=docker_vg + dest: /etc/sysconfig/docker-storage-setup + owner: root + group: root + mode: 0664 + +- name: docker storage setup + command: docker-storage-setup + register: docker_storage_setup_output + +- debug: + msg: "{{ docker_storage_setup_output }}" + +- name: extend the vg + command: lvextend -l 90%VG /dev/docker_vg/docker-pool + register: lvextend_output + +- debug: + msg: "{{ lvextend_output }}" + +- name: start docker + service: + name: docker + state: restarted + +- name: docker info + command: docker info + register: dockerinfo + +- debug: + msg: "{{ dockerinfo }}" |