From df03ad050158360c36f70b64494e8efcb278d6ae Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Fri, 21 Jul 2023 14:35:28 +0900 Subject: [PATCH] Fix unknown variable errors caused by ceph::profile::fsid Thsi fixes the unknown variable errors caused by usage of ceph::profile::fsid. The definition in ceph::profile should NOT be used by generic implementation outside of profile modules. Change-Id: I3bdb153f917838e309288b80a18af4a494d13a4d --- manifests/osd.pp | 4 ++-- manifests/profile/osd.pp | 9 ++++++++- spec/classes/ceph_osds_spec.rb | 7 +++++-- spec/defines/ceph_osd_spec.rb | 17 +---------------- 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/manifests/osd.pp b/manifests/osd.pp index e2250058..5ee76758 100644 --- a/manifests/osd.pp +++ b/manifests/osd.pp @@ -58,7 +58,7 @@ # Optional. Defaults to 'ceph_var_lib_t' # # [*fsid*] The ceph cluster FSID -# Optional. Defaults to $ceph::profile::params::fsid +# Optional. Defaults to undef, # # [*dmcrypt*] Encrypt [data-path] and/or journal devices with dm-crypt. # Optional. Defaults to false. @@ -75,7 +75,7 @@ define ceph::osd ( Optional[Enum['filestore', 'bluestore']] $store_type = undef, $exec_timeout = undef, $selinux_file_context = 'ceph_var_lib_t', - $fsid = $ceph::profile::params::fsid, + $fsid = undef, Boolean $dmcrypt = false, $dmcrypt_key_dir = '/etc/ceph/dmcrypt-keys', ) { diff --git a/manifests/profile/osd.pp b/manifests/profile/osd.pp index 4c09ab40..be348003 100644 --- a/manifests/profile/osd.pp +++ b/manifests/profile/osd.pp @@ -23,7 +23,14 @@ class ceph::profile::osd { require ceph::profile::client + if $ceph::profile::params::fsid { + $osd_defaults = {'fsid' => $ceph::profile::params::fsid} + } else { + $osd_defaults = {} + } + class { 'ceph::osds': - args => $ceph::profile::params::osds, + args => $ceph::profile::params::osds, + defaults => $osd_defaults, } } diff --git a/spec/classes/ceph_osds_spec.rb b/spec/classes/ceph_osds_spec.rb index c056daf9..20b49ed3 100644 --- a/spec/classes/ceph_osds_spec.rb +++ b/spec/classes/ceph_osds_spec.rb @@ -31,6 +31,7 @@ describe 'ceph::osds' do }, :defaults => { 'cluster' => 'CLUSTER', + 'fsid' => 'f39ace04-f967-4c3d-9fd2-32af2d2d2cd5', }, } end @@ -39,10 +40,12 @@ describe 'ceph::osds' do should contain_ceph__osd('/dev/sdb').with( :ensure => 'present', :journal => '/srv/journal', - :cluster => 'CLUSTER') + :cluster => 'CLUSTER', + :fsid => 'f39ace04-f967-4c3d-9fd2-32af2d2d2cd5') should contain_ceph__osd('/srv/data').with( :ensure => 'present', - :cluster => 'CLUSTER') + :cluster => 'CLUSTER', + :fsid => 'f39ace04-f967-4c3d-9fd2-32af2d2d2cd5') } end diff --git a/spec/defines/ceph_osd_spec.rb b/spec/defines/ceph_osd_spec.rb index 2fa8dd8b..8f5715e3 100644 --- a/spec/defines/ceph_osd_spec.rb +++ b/spec/defines/ceph_osd_spec.rb @@ -83,27 +83,12 @@ ps -fCceph-osd|grep \"\\--id \$id \" { :cluster => 'testcluster', :journal => '/srv/journal', - :fsid => 'f39ace04-f967-4c3d-9fd2-32af2d2d2cd5', :store_type => 'bluestore', :bluestore_wal => 'vg_test/lv_wal', :bluestore_db => 'vg_test/lv_db', } end - it { should contain_exec('ceph-osd-check-fsid-mismatch-vg_test/lv_test').with( - 'command' => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -exit 1 -", - 'unless' => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -if [ -z $(ceph-volume lvm list vg_test/lv_test |grep 'cluster fsid' | awk -F'fsid' '{print \$2}'|tr -d ' ') ]; then - exit 0 -fi -test f39ace04-f967-4c3d-9fd2-32af2d2d2cd5 = $(ceph-volume lvm list vg_test/lv_test |grep 'cluster fsid' | awk -F'fsid' '{print \$2}'|tr -d ' ') -", - 'logoutput' => true - ) } it { should contain_exec('ceph-osd-prepare-vg_test/lv_test').with( 'command' => "/bin/true # comment to satisfy puppet syntax requirements set -ex @@ -118,7 +103,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 --bluestore --cluster testcluster --cluster-fsid f39ace04-f967-4c3d-9fd2-32af2d2d2cd5 --data vg_test/lv_test --block.wal vg_test/lv_wal --block.db vg_test/lv_db +ceph-volume lvm prepare --bluestore --cluster testcluster --data vg_test/lv_test --block.wal vg_test/lv_wal --block.db vg_test/lv_db ", 'unless' => "/bin/true # comment to satisfy puppet syntax requirements set -ex