ceph::osd: Replace redundant handling of cluster default

Change-Id: I865db9f5975fb32a567f5deb016f75cc7c10c8b1
This commit is contained in:
Takashi Kajinami 2024-01-03 17:15:56 +09:00
parent 2bbb88eeee
commit 35f0f3630a
1 changed files with 100 additions and 105 deletions

View File

@ -48,7 +48,7 @@
# should be either filestore or bluestore.
#
# [*cluster*] The ceph cluster
# Optional. Same default as ceph.
# Optional. Defaults to ceph.
#
# [*exec_timeout*] The default exec resource timeout, in seconds
# Optional. Defaults to $ceph::params::exec_timeout
@ -69,7 +69,7 @@
define ceph::osd (
Enum['present', 'absent'] $ensure = present,
$journal = undef,
$cluster = undef,
String[1] $cluster = 'ceph',
$bluestore_wal = undef,
$bluestore_db = undef,
Optional[Enum['filestore', 'bluestore']] $store_type = undef,
@ -88,12 +88,7 @@ define ceph::osd (
$data = $name
if $cluster {
$cluster_name = $cluster
} else {
$cluster_name = 'ceph'
}
$cluster_option = "--cluster ${cluster_name}"
$cluster_option = "--cluster ${cluster}"
if $store_type {
$osd_type = " --${store_type}"
@ -163,7 +158,7 @@ test ${fsid} = $(ceph-volume lvm list ${data} |grep 'cluster fsid' | awk -F'fsid
}
#name of the bootstrap osd keyring
$bootstrap_osd_keyring = "/var/lib/ceph/bootstrap-osd/${cluster_name}.keyring"
$bootstrap_osd_keyring = "/var/lib/ceph/bootstrap-osd/${cluster}.keyring"
exec { "extract-bootstrap-osd-keyring-${name}":
command => "/bin/true # comment to satisfy puppet syntax requirements
ceph auth get client.bootstrap-osd > ${bootstrap_osd_keyring}
@ -248,15 +243,15 @@ set -ex
id=$(ceph-volume lvm list ${data} | grep 'osd id'|awk -F 'osd id' '{print \$2}'|tr -d ' ')
if [ \"\$id\" ] ; then
ceph ${cluster_option} osd out osd.\$id
stop ceph-osd cluster=${cluster_name} id=\$id || true
stop ceph-osd cluster=${cluster} id=\$id || true
service ceph stop osd.\$id || true
systemctl stop ceph-osd@\$id || true
ceph ${cluster_option} osd crush remove osd.\$id
ceph ${cluster_option} auth del osd.\$id
ceph ${cluster_option} osd rm \$id
rm -fr /var/lib/ceph/osd/${cluster_name}-\$id/*
umount /var/lib/ceph/osd/${cluster_name}-\$id || true
rm -fr /var/lib/ceph/osd/${cluster_name}-\$id
rm -fr /var/lib/ceph/osd/${cluster}-\$id/*
umount /var/lib/ceph/osd/${cluster}-\$id || true
rm -fr /var/lib/ceph/osd/${cluster}-\$id
ceph-volume lvm zap ${data}
fi
",