From afd6a03b071eced6bd0940bb96a2a39233739523 Mon Sep 17 00:00:00 2001 From: Tomas Sedovic Date: Tue, 12 Sep 2017 17:05:56 +0200 Subject: Support Cinder-backed Openshift registry (#707) * Attach and detach a volume, wait for it to be accessible This is mostly just handling the attach/detach code, making sure the necessary vars are accessible where they need to be as well as finding out the correct device name the volume is attached as. * Create temp directory for mounts, remove some debug info * add the fs actions * Remove debug * Prepare the volume automatically if possible * Add docs and sample inventory * Read OS_* creds from shell in sample inventory * Fix yamlint complaint * Update readme This mentions the potential pitfalls when using devstack. * Better check for the router deployment in CI * Set the openshift_hoster*_wait vars to True * Fix typo --- .../prepare-and-format-cinder-volume.yaml | 75 ++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 playbooks/provisioning/openstack/prepare-and-format-cinder-volume.yaml (limited to 'playbooks/provisioning/openstack/prepare-and-format-cinder-volume.yaml') diff --git a/playbooks/provisioning/openstack/prepare-and-format-cinder-volume.yaml b/playbooks/provisioning/openstack/prepare-and-format-cinder-volume.yaml new file mode 100644 index 000000000..2d630f79d --- /dev/null +++ b/playbooks/provisioning/openstack/prepare-and-format-cinder-volume.yaml @@ -0,0 +1,75 @@ +--- +- hosts: localhost + gather_facts: False + become: False + tasks: + - set_fact: + cinder_volume: "{{ hostvars[groups.masters[0]].openshift_hosted_registry_storage_openstack_volumeID }}" + cinder_fs: "{{ hostvars[groups.masters[0]].openshift_hosted_registry_storage_openstack_filesystem }}" + + - name: Attach the volume to the VM + os_server_volume: + state: present + server: "{{ groups['masters'][0] }}" + volume: "{{ cinder_volume }}" + register: volume_attachment + + - set_fact: + attached_device: >- + {{ volume_attachment['attachments']|json_query("[?volume_id=='" + cinder_volume + "'].device | [0]") }} + + +- hosts: masters[0] + gather_facts: False + become: True + tasks: + - name: Wait for the device to appear + wait_for: path={{ hostvars['localhost'].attached_device }} + + - name: Create a temp directory for mounting the volume + tempfile: + prefix: cinder-volume + state: directory + register: cinder_mount_dir + + - name: Format the device + filesystem: + fstype: "{{ openshift_hosted_registry_storage_openstack_filesystem }}" + dev: "{{ hostvars['localhost'].attached_device }}" + + - name: Mount the device + mount: + name: "{{ cinder_mount_dir.path }}" + src: "{{ hostvars['localhost'].attached_device }}" + state: mounted + fstype: "{{ openshift_hosted_registry_storage_openstack_filesystem }}" + + - name: Change mode on the filesystem + file: + path: "{{ cinder_mount_dir.path }}" + state: directory + recurse: true + mode: 0777 + + - name: Unmount the device + mount: + name: "{{ cinder_mount_dir.path }}" + src: "{{ hostvars['localhost'].attached_device }}" + state: absent + fstype: "{{ openshift_hosted_registry_storage_openstack_filesystem }}" + + - name: Delete the temp directory + file: + name: "{{ cinder_mount_dir.path }}" + state: absent + + +- hosts: localhost + gather_facts: False + become: False + tasks: + - name: Detach the volume from the VM + os_server_volume: + state: absent + server: "{{ groups['masters'][0] }}" + volume: "{{ cinder_volume }}" -- cgit v1.2.3