diff options
author | Tomas Sedovic <tomas@sedovic.cz> | 2017-09-12 17:05:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-12 17:05:56 +0200 |
commit | afd6a03b071eced6bd0940bb96a2a39233739523 (patch) | |
tree | 0c16d74a9e341aa3c48149e0a049b077b4ecfd5d /playbooks/provisioning/openstack/prepare-and-format-cinder-volume.yaml | |
parent | 2d3fae8f65a234ecd66fdaa6017d9158616ab256 (diff) | |
download | openshift-afd6a03b071eced6bd0940bb96a2a39233739523.tar.gz openshift-afd6a03b071eced6bd0940bb96a2a39233739523.tar.bz2 openshift-afd6a03b071eced6bd0940bb96a2a39233739523.tar.xz openshift-afd6a03b071eced6bd0940bb96a2a39233739523.zip |
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
Diffstat (limited to 'playbooks/provisioning/openstack/prepare-and-format-cinder-volume.yaml')
-rw-r--r-- | playbooks/provisioning/openstack/prepare-and-format-cinder-volume.yaml | 75 |
1 files changed, 75 insertions, 0 deletions
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 }}" |