summaryrefslogtreecommitdiffstats
path: root/roles
diff options
context:
space:
mode:
authorMatt Woodson <mwoodson@redhat.com>2016-02-29 12:14:47 -0500
committerMatt Woodson <mwoodson@redhat.com>2016-02-29 12:14:47 -0500
commit5e05db87e0788e99a46bfb170f11e1ce8a8dcd1e (patch)
treea5a005a7b07d89e71c0aae3e6c3bbefcdaefe62b /roles
parent0d07fdcd68cf1e8b64a177a7f01be2571e27c21e (diff)
downloadopenshift-5e05db87e0788e99a46bfb170f11e1ce8a8dcd1e.tar.gz
openshift-5e05db87e0788e99a46bfb170f11e1ce8a8dcd1e.tar.bz2
openshift-5e05db87e0788e99a46bfb170f11e1ce8a8dcd1e.tar.xz
openshift-5e05db87e0788e99a46bfb170f11e1ce8a8dcd1e.zip
role: added docker_storage_setup
Diffstat (limited to 'roles')
-rw-r--r--roles/docker_storage/tasks/main.yml4
-rw-r--r--roles/docker_storage_setup/README.md42
-rw-r--r--roles/docker_storage_setup/defaults/main.yml2
-rwxr-xr-xroles/docker_storage_setup/tasks/main.yml82
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 }}"