Remove hardcoded reference to cinder LVM loopback device

Replace hardcoded reference to "/dev/loop2" by allowing losetup to
dynamically choose the next available loopback device number.

Eliminate hiera data that set cinder_lvm_loop_device_size. This is not
needed because the associated file is created by a host prep task, and
the puppet code will be removed by https://review.opendev.org/720139.

Closes-Bug: #1872881
Change-Id: Ia0302d1d55dcb8333d7db9713822075d32cd852a
This commit is contained in:
Alan Bishop 2020-04-15 08:41:56 -07:00
parent f85caaf411
commit 502947b4be
2 changed files with 14 additions and 14 deletions

View File

@ -106,21 +106,26 @@ outputs:
- 'M'
args:
creates: /var/lib/cinder/cinder-volumes
- name: cinder create LVM loopback device
command:
losetup -f /var/lib/cinder/cinder-volumes
- name: cinder identify the LVM loopback device
command:
losetup -j /var/lib/cinder/cinder-volumes -n -O NAME
register: cinder_lvm_loopback_device
- name: set cinder_lvm_dev fact
set_fact:
cinder_lvm_dev: "{{ cinder_lvm_loopback_device.stdout|default('') }}"
- name: cinder create LVM volume group
shell: |
if ! losetup /dev/loop2; then
losetup /dev/loop2 /var/lib/cinder/cinder-volumes
fi
if ! pvdisplay | grep cinder-volumes; then
pvcreate /dev/loop2
pvcreate {{ cinder_lvm_dev }}
fi
if ! vgdisplay | grep cinder-volumes; then
vgcreate cinder-volumes /dev/loop2
vgcreate cinder-volumes {{ cinder_lvm_dev }}
fi
touch /dev/loop2cinder
args:
executable: /bin/bash
creates: /dev/loop2cinder
- name: cinder create service to run losetup for LVM on startup
copy:
dest: /etc/systemd/system/cinder-lvm-losetup.service
@ -131,8 +136,8 @@ outputs:
[Service]
Type=oneshot
ExecStart=/bin/bash -c '/sbin/losetup /dev/loop2 || /sbin/losetup /dev/loop2 /var/lib/cinder/cinder-volumes'
ExecStop=/bin/bash -c '/sbin/losetup -d /dev/loop2'
ExecStart=/bin/bash -c '/sbin/losetup {{ cinder_lvm_dev }} || /sbin/losetup {{ cinder_lvm_dev }} /var/lib/cinder/cinder-volumes'
ExecStop=/bin/bash -c '/sbin/losetup -d {{ cinder_lvm_dev }}'
RemainAfterExit=yes
[Install]

View File

@ -92,10 +92,6 @@ parameters:
default: iscsi
description: Whether to use TCP ('iscsi') or iSER RDMA ('iser') for iSCSI
type: string
CinderLVMLoopDeviceSize:
default: 10280
description: The size of the loopback file used by the cinder LVM driver.
type: number
CinderNfsAvailabilityZone:
default: ''
description: >
@ -215,7 +211,6 @@ outputs:
tripleo::profile::base::cinder::volume::nfs::cinder_nfs_snapshot_support: {get_param: CinderNfsSnapshotSupport}
tripleo::profile::base::cinder::volume::nfs::cinder_nas_secure_file_operations: {get_param: CinderNasSecureFileOperations}
tripleo::profile::base::cinder::volume::nfs::cinder_nas_secure_file_permissions: {get_param: CinderNasSecureFilePermissions}
tripleo::profile::base::cinder::volume::iscsi::cinder_lvm_loop_device_size: {get_param: CinderLVMLoopDeviceSize}
tripleo::profile::base::cinder::volume::iscsi::cinder_iscsi_helper: {get_param: CinderISCSIHelper}
tripleo::profile::base::cinder::volume::iscsi::cinder_iscsi_protocol: {get_param: CinderISCSIProtocol}
tripleo::profile::base::cinder::volume::rbd::cinder_rbd_ceph_conf: