Kolla: Add support for cinder on device
Add support for an actual HDD or device, instead of loopback
installer-type: kolla
deploy-scenario: os-nosdn-nofeature
Change-Id: If1f8d24294704b81d6d8b22a8126db36fc10f96f
diff --git a/playbooks/roles/configure-targethosts/tasks/main.yml b/playbooks/roles/configure-targethosts/tasks/main.yml
index 3a02d5f..783f029 100644
--- a/playbooks/roles/configure-targethosts/tasks/main.yml
+++ b/playbooks/roles/configure-targethosts/tasks/main.yml
@@ -22,7 +22,7 @@
- include: sync-time.yml
- include: create-swap.yml
- include: prepare-nova-kvm.yml
-- include: prepare-cinder-{{ cinder_storage_driver }}.yml
+- include: prepare-cinder-{{ cinder_storage_driver }}-{{ cinder_storage_type }}.yml
- include: prepare-cinder-backup-{{ cinder_storage_backup_driver }}.yml
# vim: set ts=2 sw=2 expandtab:
diff --git a/playbooks/roles/configure-targethosts/tasks/prepare-cinder-ceph-device.yml b/playbooks/roles/configure-targethosts/tasks/prepare-cinder-ceph-device.yml
new file mode 100644
index 0000000..f9660f9
--- /dev/null
+++ b/playbooks/roles/configure-targethosts/tasks/prepare-cinder-ceph-device.yml
@@ -0,0 +1,41 @@
+---
+# ============LICENSE_START=======================================================
+# Copyright (C) 2019 The Nordix Foundation. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+
+- name: Read "{{ cinder_volume_device }}" volume information
+ parted:
+ device: "{{ cinder_volume_device }}"
+ unit: "MiB"
+ register: device_info
+
+- name: Remove all partitions from disk
+ parted:
+ device: "{{ cinder_volume_device }}"
+ number: '{{ item.num }}'
+ state: absent
+ loop: '{{ device_info.partitions }}'
+
+- name: Create Ceph RBD partition
+ parted:
+ label: gpt
+ state: present
+ device: "{{ cinder_volume_device }}"
+ number: 1
+ name: "{{ ceph_partition_name }}"
+
+# vim: set ts=2 sw=2 expandtab:
diff --git a/playbooks/roles/configure-targethosts/tasks/prepare-cinder-ceph.yml b/playbooks/roles/configure-targethosts/tasks/prepare-cinder-ceph-loopback.yml
similarity index 91%
rename from playbooks/roles/configure-targethosts/tasks/prepare-cinder-ceph.yml
rename to playbooks/roles/configure-targethosts/tasks/prepare-cinder-ceph-loopback.yml
index d308eab..f14862e 100644
--- a/playbooks/roles/configure-targethosts/tasks/prepare-cinder-ceph.yml
+++ b/playbooks/roles/configure-targethosts/tasks/prepare-cinder-ceph-loopback.yml
@@ -19,7 +19,7 @@
- name: Check for cinder image
stat:
- path: "{{ cinder_image_path }}"
+ path: "{{ cinder_volume_path }}"
register: cinder_image
ignore_errors: true
@@ -35,7 +35,7 @@
- name: Remove cinder image
file:
- path: "{{ cinder_image_path }}"
+ path: "{{ cinder_volume_path }}"
state: absent
ignore_errors: true
when: cinder_image.stat.exists
@@ -50,9 +50,9 @@
loopback_device_name: "{{ free_device.stdout }}"
- name: Create cinder image
- command: "fallocate -l {{ cinder_image_size }} {{ cinder_image_path }}"
+ command: "fallocate -l {{ cinder_volume_size }} {{ cinder_volume_path }}"
args:
- creates: "{{ cinder_image_path }}"
+ creates: "{{ cinder_volume_path }}"
- name: Create cinder loopback service
template:
diff --git a/playbooks/roles/configure-targethosts/tasks/prepare-cinder-lvm-device.yml b/playbooks/roles/configure-targethosts/tasks/prepare-cinder-lvm-device.yml
new file mode 100644
index 0000000..d7bd99c
--- /dev/null
+++ b/playbooks/roles/configure-targethosts/tasks/prepare-cinder-lvm-device.yml
@@ -0,0 +1,32 @@
+---
+# ============LICENSE_START=======================================================
+# Copyright (C) 2019 The Nordix Foundation. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+
+- name: Remove cinder-volumes volume group if it exists
+ lvg:
+ vg: cinder-volumes
+ state: absent
+ force: true
+ ignore_errors: true
+
+- name: Add cinder-volumes volume group
+ lvg:
+ vg: cinder-volumes
+ pvs: "{{ cinder_volume_device }}"
+
+# vim: set ts=2 sw=2 expandtab:
diff --git a/playbooks/roles/configure-targethosts/tasks/prepare-cinder-lvm.yml b/playbooks/roles/configure-targethosts/tasks/prepare-cinder-lvm-loopback.yml
similarity index 92%
rename from playbooks/roles/configure-targethosts/tasks/prepare-cinder-lvm.yml
rename to playbooks/roles/configure-targethosts/tasks/prepare-cinder-lvm-loopback.yml
index 58dbd99..7230c44 100644
--- a/playbooks/roles/configure-targethosts/tasks/prepare-cinder-lvm.yml
+++ b/playbooks/roles/configure-targethosts/tasks/prepare-cinder-lvm-loopback.yml
@@ -28,7 +28,7 @@
- name: Check for cinder image
stat:
- path: "{{ cinder_image_path }}"
+ path: "{{ cinder_volume_path }}"
register: cinder_image
ignore_errors: true
@@ -48,7 +48,7 @@
- name: Remove cinder image
file:
- path: "{{ cinder_image_path }}"
+ path: "{{ cinder_volume_path }}"
state: absent
ignore_errors: true
when: cinder_image.stat.exists
@@ -63,9 +63,9 @@
loopback_device_name: "{{ free_device.stdout }}"
- name: Create cinder image
- command: "fallocate -l {{ cinder_image_size }} {{ cinder_image_path }}"
+ command: "fallocate -l {{ cinder_volume_size }} {{ cinder_volume_path }}"
args:
- creates: "{{ cinder_image_path }}"
+ creates: "{{ cinder_volume_path }}"
- name: Create cinder loopback service
template:
diff --git a/playbooks/roles/configure-targethosts/templates/cinder-loopback.service.j2 b/playbooks/roles/configure-targethosts/templates/cinder-loopback.service.j2
index 6f47739..0cc0bea 100644
--- a/playbooks/roles/configure-targethosts/templates/cinder-loopback.service.j2
+++ b/playbooks/roles/configure-targethosts/templates/cinder-loopback.service.j2
@@ -6,7 +6,7 @@
Wants=systemd-udev-settle.service
[Service]
-ExecStart=/sbin/losetup {{ loopback_device_name }} {{ cinder_image_path }}
+ExecStart=/sbin/losetup {{ loopback_device_name }} {{ cinder_volume_path }}
Type=oneshot
[Install]