Add ceph backend for cinder
installer-type: kolla
deploy-scenario: os-nosdn-nofeature
Change-Id: I0657fa33f878051d798031bf449fc03fe6fe803a
diff --git a/playbooks/roles/configure-installer/tasks/main.yml b/playbooks/roles/configure-installer/tasks/main.yml
index 7db1dfa..f3c80f9 100644
--- a/playbooks/roles/configure-installer/tasks/main.yml
+++ b/playbooks/roles/configure-installer/tasks/main.yml
@@ -88,6 +88,11 @@
src: keystone.conf.j2
dest: "{{ config_path }}/keystone.conf"
+- name: Place custom ceph configuration
+ template:
+ src: ceph.conf.j2
+ dest: "{{ config_path }}/ceph.conf"
+
- name: Generate kolla passwords
command: "{{ kolla_ansible_path }}/tools/generate_passwords.py -p {{ config_path }}/passwords.yml"
changed_when: false
diff --git a/playbooks/roles/configure-installer/templates/ceph.conf.j2 b/playbooks/roles/configure-installer/templates/ceph.conf.j2
new file mode 100644
index 0000000..444d623
--- /dev/null
+++ b/playbooks/roles/configure-installer/templates/ceph.conf.j2
@@ -0,0 +1,25 @@
+# ============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=========================================================
+
+# See: https://docs.openstack.org/kolla-ansible/latest/reference/storage/ceph-guide.html#managing-ceph
+# If Ceph is run in an all-in-one deployment or with less than three storage nodes,
+# further configuration is required. It is necessary to change the default number of
+# copies for the pool.
+[global]
+osd pool default size = 1
+osd pool default min size = 1
diff --git a/playbooks/roles/configure-installer/templates/kolla-ansible-extra-vars.j2 b/playbooks/roles/configure-installer/templates/kolla-ansible-extra-vars.j2
index 2fcf124..fa7f1c6 100644
--- a/playbooks/roles/configure-installer/templates/kolla-ansible-extra-vars.j2
+++ b/playbooks/roles/configure-installer/templates/kolla-ansible-extra-vars.j2
@@ -29,10 +29,16 @@
# cinder specific options
enable_cinder: "yes"
-enable_cinder_backend_lvm: "yes"
enable_cinder_backup: "yes"
-cinder_backup_driver: "nfs"
+enable_cinder_backend_lvm: "{{ (cinder_storage_driver == 'lvm') | ternary('yes','no') }}"
+enable_ceph: "{{ (cinder_storage_driver == 'ceph') | ternary('yes','no') }}"
+cinder_backup_driver: "{{ cinder_storage_backup_driver }}"
cinder_backup_share: "{{ os_kolla_internal_vip_address }}:{{ cinder_backup_path }}"
+# ceph specific options
+# See: https://docs.ceph.com/docs/mimic/rados/operations/placement-groups/#a-preselection-of-pg-num
+ceph_pool_pg_num: 32
+ceph_pool_pgp_num: 32
+
# Nova compute virt_type is set in inventory
nova_compute_virt_type: "{{ (lookup('env', 'BAREMETAL') == 'true') | ternary('kvm','qemu') }}"
diff --git a/playbooks/roles/configure-targethosts/tasks/install-packages-Debian.yml b/playbooks/roles/configure-targethosts/tasks/install-packages-Debian.yml
index 05b9a76..ab8cf63 100644
--- a/playbooks/roles/configure-targethosts/tasks/install-packages-Debian.yml
+++ b/playbooks/roles/configure-targethosts/tasks/install-packages-Debian.yml
@@ -33,6 +33,7 @@
- "lvm2"
- "nfs-kernel-server"
- "tzdata"
+ - "parted"
# NOTE: raw install is required to support cloud images which do not have python installed
# This is copied from kolla-ansible: ansible/roles/baremetal/tasks/pre-install.yml
diff --git a/playbooks/roles/configure-targethosts/tasks/install-packages-RedHat.yml b/playbooks/roles/configure-targethosts/tasks/install-packages-RedHat.yml
index 4c46f95..29a64b3 100644
--- a/playbooks/roles/configure-targethosts/tasks/install-packages-RedHat.yml
+++ b/playbooks/roles/configure-targethosts/tasks/install-packages-RedHat.yml
@@ -30,5 +30,6 @@
- "lvm2"
- "nfs-kernel-server"
- "tzdata"
+ - "parted"
# vim: set ts=2 sw=2 expandtab:
diff --git a/playbooks/roles/configure-targethosts/tasks/main.yml b/playbooks/roles/configure-targethosts/tasks/main.yml
index e33f6be..3fde5ec 100644
--- a/playbooks/roles/configure-targethosts/tasks/main.yml
+++ b/playbooks/roles/configure-targethosts/tasks/main.yml
@@ -21,7 +21,7 @@
- include: install-packages.yml
- include: sync-time.yml
- include: create-swap.yml
-- include: prepare-cinder-lvm-backend.yml
-- include: prepare-cinder-nfs-backup.yml
+- include: prepare-cinder-{{ cinder_storage_driver }}.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-nfs-backup.yml b/playbooks/roles/configure-targethosts/tasks/prepare-cinder-backup-nfs.yml
similarity index 100%
rename from playbooks/roles/configure-targethosts/tasks/prepare-cinder-nfs-backup.yml
rename to playbooks/roles/configure-targethosts/tasks/prepare-cinder-backup-nfs.yml
diff --git a/playbooks/roles/configure-targethosts/tasks/prepare-cinder-lvm-backend.yml b/playbooks/roles/configure-targethosts/tasks/prepare-cinder-ceph.yml
similarity index 79%
copy from playbooks/roles/configure-targethosts/tasks/prepare-cinder-lvm-backend.yml
copy to playbooks/roles/configure-targethosts/tasks/prepare-cinder-ceph.yml
index 4052305..60bbe62 100644
--- a/playbooks/roles/configure-targethosts/tasks/prepare-cinder-lvm-backend.yml
+++ b/playbooks/roles/configure-targethosts/tasks/prepare-cinder-ceph.yml
@@ -16,15 +16,6 @@
#
# SPDX-License-Identifier: Apache-2.0
# ============LICENSE_END=========================================================
-- name: Run pvscan
- command: "pvscan"
- changed_when: false
-
-- name: Remove cinder-volumes volume group if it exists
- lvg:
- vg: cinder-volumes
- state: absent
- ignore_errors: yes
- name: Check for cinder image
stat:
@@ -38,10 +29,6 @@
register: cinder_device
ignore_errors: yes
- - name: Delete PV on loopback device
- command: "pvremove {{ cinder_device.stdout }}"
- ignore_errors: yes
-
- name: Delete loopback device
command: "losetup -d {{ cinder_device.stdout }}"
ignore_errors: yes
@@ -73,19 +60,22 @@
dest: "/etc/systemd/system/cinder-loopback.service"
become: true
+- name: Force systemd to reread service configs
+ systemd:
+ daemon_reload: yes
+
- name: Enable and start cinder loopback service
systemd:
name: cinder-loopback
enabled: true
state: started
-- name: Create PV on the loopback device
- command: "pvcreate {{ loopback_device_name }}"
- changed_when: false
-
-- name: Add cinder-volumes volume group
- lvg:
- vg: cinder-volumes
- pvs: "{{ loopback_device_name }}"
+- name: Create Ceph RBD partition
+ parted:
+ label: gpt
+ state: present
+ device: "{{ loopback_device_name }}"
+ number: 1
+ name: "{{ ceph_partition_name }}"
# vim: set ts=2 sw=2 expandtab:
diff --git a/playbooks/roles/configure-targethosts/tasks/prepare-cinder-lvm-backend.yml b/playbooks/roles/configure-targethosts/tasks/prepare-cinder-lvm.yml
similarity index 96%
rename from playbooks/roles/configure-targethosts/tasks/prepare-cinder-lvm-backend.yml
rename to playbooks/roles/configure-targethosts/tasks/prepare-cinder-lvm.yml
index 4052305..19c35f1 100644
--- a/playbooks/roles/configure-targethosts/tasks/prepare-cinder-lvm-backend.yml
+++ b/playbooks/roles/configure-targethosts/tasks/prepare-cinder-lvm.yml
@@ -73,6 +73,10 @@
dest: "/etc/systemd/system/cinder-loopback.service"
become: true
+- name: Force systemd to reread service configs
+ systemd:
+ daemon_reload: yes
+
- name: Enable and start cinder loopback service
systemd:
name: cinder-loopback
diff --git a/playbooks/roles/configure-targethosts/vars/main.yml b/playbooks/roles/configure-targethosts/vars/main.yml
index 713069b..7986d5f 100644
--- a/playbooks/roles/configure-targethosts/vars/main.yml
+++ b/playbooks/roles/configure-targethosts/vars/main.yml
@@ -17,7 +17,7 @@
# SPDX-License-Identifier: Apache-2.0
# ============LICENSE_END=========================================================
-cinder_image_size: "10G"
+ceph_partition_name: "KOLLA_CEPH_OSD_BOOTSTRAP_BS"
nfs_exports_file: "/etc/exports"
nfs_network: "{{ idf.net_config.mgmt.network }}/{{ idf.net_config.mgmt.mask }}"