From 8bc67e20e7e1b95b1264b9fa772a26b470e7bd70 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 17 Jul 2023 22:34:13 +0900 Subject: [PATCH] Partially fix undefined variables This is the first step to get rid of the errors found in unit tests with Puppet 8, and fixes some undefined variables found in ceph::osd. This also fixes a few redundant spaces appearing in commands. Change-Id: I52b26701e77af44e8fb80106a6d1b6dbd34f133d --- manifests/osd.pp | 18 ++++++++++++------ spec/defines/ceph_osd_spec.rb | 10 +++++----- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/manifests/osd.pp b/manifests/osd.pp index 46227d1e..7f0b863e 100644 --- a/manifests/osd.pp +++ b/manifests/osd.pp @@ -92,7 +92,7 @@ define ceph::osd ( $cluster_option = "--cluster ${cluster_name}" if $store_type { - $osd_type = "--${store_type}" + $osd_type = " --${store_type}" } else { $osd_type = '' } @@ -100,14 +100,18 @@ define ceph::osd ( if ($bluestore_wal) or ($bluestore_db) { if $bluestore_wal { $wal_opts = "--block.wal ${bluestore_wal}" + } else { + $wal_opts = undef } + if $bluestore_db { $block_opts = "--block.db ${bluestore_db}" + } else { + $block_opts = undef } - $journal_opts = "${wal_opts} ${block_opts}" - + $journal_opts = join(delete_undef_values(['', $wal_opts, $block_opts]), ' ') } elsif $journal { - $journal_opts = "--journal ${journal}" + $journal_opts = " --journal ${journal}" } else { $journal_opts = '' } @@ -131,7 +135,7 @@ define ceph::osd ( Exec<| tag == 'prepare' |> -> Exec<| tag == 'activate' |> if $fsid { - $fsid_option = "--cluster-fsid ${fsid}" + $fsid_option = " --cluster-fsid ${fsid}" $ceph_check_fsid_mismatch = "ceph-osd-check-fsid-mismatch-${name}" Exec[$ceph_check_fsid_mismatch] -> Exec[$ceph_prepare] # return error if $(readlink -f ${data}) has fsid differing from ${fsid}, unless there is no fsid @@ -150,6 +154,8 @@ test ${fsid} = $(ceph-volume lvm list ${data} |grep 'cluster fsid' | awk -F'fsid logoutput => true, timeout => $exec_timeout, } + } else { + $fsid_option = '' } #name of the bootstrap osd keyring @@ -176,7 +182,7 @@ if ! test -b \$disk ; then # Since nautilus, only block devices or lvm logical volumes can be used for OSDs exit 1 fi -ceph-volume lvm prepare ${osd_type} ${cluster_option}${dmcrypt_options} ${fsid_option} --data ${data} ${journal_opts} +ceph-volume lvm prepare${osd_type} ${cluster_option}${dmcrypt_options}${fsid_option} --data ${data}${journal_opts} ", unless => "/bin/true # comment to satisfy puppet syntax requirements set -ex diff --git a/spec/defines/ceph_osd_spec.rb b/spec/defines/ceph_osd_spec.rb index 16544e8e..8d02df7d 100644 --- a/spec/defines/ceph_osd_spec.rb +++ b/spec/defines/ceph_osd_spec.rb @@ -40,7 +40,7 @@ if ! test -b \$disk ; then # Since nautilus, only block devices or lvm logical volumes can be used for OSDs exit 1 fi -ceph-volume lvm prepare --cluster ceph --data vg_test/lv_test +ceph-volume lvm prepare --cluster ceph --data vg_test/lv_test ", 'unless' => "/bin/true # comment to satisfy puppet syntax requirements set -ex @@ -178,7 +178,7 @@ if ! test -b \$disk ; then # Since nautilus, only block devices or lvm logical volumes can be used for OSDs exit 1 fi -ceph-volume lvm prepare --cluster ceph --dmcrypt --dmcrypt-key-dir '/etc/ceph/dmcrypt-keys' --data /dev/sdc +ceph-volume lvm prepare --cluster ceph --dmcrypt --dmcrypt-key-dir '/etc/ceph/dmcrypt-keys' --data /dev/sdc ", 'unless' => "/bin/true # comment to satisfy puppet syntax requirements set -ex @@ -239,7 +239,7 @@ if ! test -b \$disk ; then # Since nautilus, only block devices or lvm logical volumes can be used for OSDs exit 1 fi -ceph-volume lvm prepare --cluster ceph --dmcrypt --dmcrypt-key-dir '/srv/ceph/keys' --data /dev/sdc +ceph-volume lvm prepare --cluster ceph --dmcrypt --dmcrypt-key-dir '/srv/ceph/keys' --data /dev/sdc ", 'unless' => "/bin/true # comment to satisfy puppet syntax requirements set -ex @@ -369,7 +369,7 @@ if ! test -b \$disk ; then # Since nautilus, only block devices or lvm logical volumes can be used for OSDs exit 1 fi -ceph-volume lvm prepare --cluster ceph --data /dev/nvme0n1 +ceph-volume lvm prepare --cluster ceph --data /dev/nvme0n1 ", 'unless' => "/bin/true # comment to satisfy puppet syntax requirements set -ex @@ -423,7 +423,7 @@ if ! test -b \$disk ; then # Since nautilus, only block devices or lvm logical volumes can be used for OSDs exit 1 fi -ceph-volume lvm prepare --cluster ceph --data /dev/cciss/c0d0 +ceph-volume lvm prepare --cluster ceph --data /dev/cciss/c0d0 ", 'unless' => "/bin/true # comment to satisfy puppet syntax requirements set -ex