summaryrefslogtreecommitdiffstats
path: root/roles/openshift_openstack/tasks/prepare-and-format-cinder-volume.yaml
diff options
context:
space:
mode:
authorScott Dodson <sdodson@redhat.com>2017-11-16 08:53:17 -0500
committerGitHub <noreply@github.com>2017-11-16 08:53:17 -0500
commit8a85bc3a00efb654238a58e1faa2a2629d9360b1 (patch)
tree693186d957899c6e3cd38a6ae5aa66392814ff15 /roles/openshift_openstack/tasks/prepare-and-format-cinder-volume.yaml
parent7dcc6292e2ca89fe22675491299cf5853860bed8 (diff)
parent2e9d134d4564d87dbbc7853b07204f7f44ee01e6 (diff)
downloadopenshift-8a85bc3a00efb654238a58e1faa2a2629d9360b1.tar.gz
openshift-8a85bc3a00efb654238a58e1faa2a2629d9360b1.tar.bz2
openshift-8a85bc3a00efb654238a58e1faa2a2629d9360b1.tar.xz
openshift-8a85bc3a00efb654238a58e1faa2a2629d9360b1.zip
Merge pull request #6039 from tomassedovic/openstack-provider-githist
Add the OpenStack provider
Diffstat (limited to 'roles/openshift_openstack/tasks/prepare-and-format-cinder-volume.yaml')
-rw-r--r--roles/openshift_openstack/tasks/prepare-and-format-cinder-volume.yaml59
1 files changed, 59 insertions, 0 deletions
diff --git a/roles/openshift_openstack/tasks/prepare-and-format-cinder-volume.yaml b/roles/openshift_openstack/tasks/prepare-and-format-cinder-volume.yaml
new file mode 100644
index 000000000..fc51f6dc2
--- /dev/null
+++ b/roles/openshift_openstack/tasks/prepare-and-format-cinder-volume.yaml
@@ -0,0 +1,59 @@
+---
+- 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]") }}
+
+- delegate_to: "{{ groups['masters'][0] }}"
+ block:
+ - name: Wait for the device to appear
+ wait_for: path={{ 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: "{{ cinder_fs }}"
+ dev: "{{ attached_device }}"
+
+ - name: Mount the device
+ mount:
+ name: "{{ cinder_mount_dir.path }}"
+ src: "{{ attached_device }}"
+ state: mounted
+ fstype: "{{ cinder_fs }}"
+
+ - 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: "{{ attached_device }}"
+ state: absent
+ fstype: "{{ cinder_fs }}"
+
+ - name: Delete the temp directory
+ file:
+ name: "{{ cinder_mount_dir.path }}"
+ state: absent
+
+- name: Detach the volume from the VM
+ os_server_volume:
+ state: absent
+ server: "{{ groups['masters'][0] }}"
+ volume: "{{ cinder_volume }}"