From db8e683898b768169a6b5c1bb30be0de7b1e6e37 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Tue, 9 Jan 2024 21:23:52 +0900 Subject: [PATCH] Get rid of script workaround for single command calls ... to simplify the command called by the exec resources. Change-Id: Ib7942c0795532bfe4448225fe64767dcebf1a537 --- manifests/fs.pp | 9 ++---- manifests/pool.pp | 54 ++++++++++++---------------------- spec/defines/ceph_fs_spec.rb | 5 ++-- spec/defines/ceph_pool_spec.rb | 18 ++++++++---- 4 files changed, 36 insertions(+), 50 deletions(-) diff --git a/manifests/fs.pp b/manifests/fs.pp index ae34764d..21b81de6 100644 --- a/manifests/fs.pp +++ b/manifests/fs.pp @@ -52,12 +52,9 @@ define ceph::fs ( Ceph::Pool<||> -> Exec["create-fs-${name}"] exec { "create-fs-${name}": - command => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -ceph fs new ${name} ${metadata_pool} ${data_pool}", - unless => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -ceph fs ls | grep 'name: ${name},'", + command => "ceph fs new ${name} ${metadata_pool} ${data_pool}", + unless => "ceph fs ls | grep 'name: ${name},'", + path => ['/bin', '/usr/bin'], timeout => $exec_timeout_real, } } diff --git a/manifests/pool.pp b/manifests/pool.pp index ee1a1220..f87991ea 100644 --- a/manifests/pool.pp +++ b/manifests/pool.pp @@ -72,34 +72,25 @@ define ceph::pool ( Ceph::Key<||> -> Exec["create-${name}"] Ceph::Osd<||> -> Exec["create-${name}"] exec { "create-${name}": - command => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -ceph osd pool create ${name} ${pg_num}", - unless => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -ceph osd pool ls | grep -w '${name}'", + command => "ceph osd pool create ${name} ${pg_num}", + unless => "ceph osd pool ls | grep -w '${name}'", + path => ['/bin', '/usr/bin'], timeout => $exec_timeout_real, } exec { "set-${name}-pg_num": - command => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -ceph osd pool set ${name} pg_num ${pg_num}", - unless => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -test $(ceph osd pool get ${name} pg_num | sed 's/.*:\s*//g') -ge ${pg_num}", + command => "ceph osd pool set ${name} pg_num ${pg_num}", + unless => "test $(ceph osd pool get ${name} pg_num | sed 's/.*:\s*//g') -ge ${pg_num}", + path => ['/bin', '/usr/bin'], require => Exec["create-${name}"], timeout => $exec_timeout_real, } if $pgp_num { exec { "set-${name}-pgp_num": - command => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -ceph osd pool set ${name} pgp_num ${pgp_num}", - unless => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -test $(ceph osd pool get ${name} pgp_num | sed 's/.*:\s*//g') -ge ${pgp_num}", + command => "ceph osd pool set ${name} pgp_num ${pgp_num}", + unless => "test $(ceph osd pool get ${name} pgp_num | sed 's/.*:\s*//g') -ge ${pgp_num}", + path => ['/bin', '/usr/bin'], require => [Exec["create-${name}"], Exec["set-${name}-pg_num"]], timeout => $exec_timeout_real, } @@ -107,12 +98,9 @@ test $(ceph osd pool get ${name} pgp_num | sed 's/.*:\s*//g') -ge ${pgp_num}", if $size { exec { "set-${name}-size": - command => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -ceph osd pool set ${name} size ${size}", - unless => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -test $(ceph osd pool get ${name} size | sed 's/.*:\s*//g') -eq ${size}", + command => "ceph osd pool set ${name} size ${size}", + unless => "test $(ceph osd pool get ${name} size | sed 's/.*:\s*//g') -eq ${size}", + path => ['/bin', '/usr/bin'], require => Exec["create-${name}"], timeout => $exec_timeout_real, } @@ -120,12 +108,9 @@ test $(ceph osd pool get ${name} size | sed 's/.*:\s*//g') -eq ${size}", if $tag { exec { "set-${name}-tag": - command => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -ceph osd pool application enable ${name} ${tag}", - unless => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -ceph osd pool application get ${name} ${tag}", + command => "ceph osd pool application enable ${name} ${tag}", + unless => "ceph osd pool application get ${name} ${tag}", + path => ['/bin', '/usr/bin'], require => Exec["create-${name}"], timeout => $exec_timeout_real, } @@ -134,12 +119,9 @@ ceph osd pool application get ${name} ${tag}", } else { exec { "delete-${name}": - command => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -ceph osd pool delete ${name} ${name} --yes-i-really-really-mean-it", - onlyif => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -ceph osd pool ls | grep -w '${name}'", + command => "ceph osd pool delete ${name} ${name} --yes-i-really-really-mean-it", + onlyif => "ceph osd pool ls | grep -w '${name}'", + path => ['/bin', '/usr/bin'], timeout => $exec_timeout_real, } -> Ceph::Mon<| ensure == absent |> diff --git a/spec/defines/ceph_fs_spec.rb b/spec/defines/ceph_fs_spec.rb index 759d619e..ef2e61d3 100644 --- a/spec/defines/ceph_fs_spec.rb +++ b/spec/defines/ceph_fs_spec.rb @@ -30,8 +30,9 @@ describe 'ceph::fs' do end it { should contain_exec('create-fs-fsa').with( - :command => "/bin/true # comment to satisfy puppet syntax requirements\nset -ex\nceph fs new fsa metadata_pool data_pool", - :unless => "/bin/true # comment to satisfy puppet syntax requirements\nset -ex\nceph fs ls | grep 'name: fsa,'" + :command => "ceph fs new fsa metadata_pool data_pool", + :unless => "ceph fs ls | grep 'name: fsa,'", + :path => ['/bin', '/usr/bin'], )} end end diff --git a/spec/defines/ceph_pool_spec.rb b/spec/defines/ceph_pool_spec.rb index 7c9f688c..6f71fe29 100644 --- a/spec/defines/ceph_pool_spec.rb +++ b/spec/defines/ceph_pool_spec.rb @@ -37,19 +37,24 @@ describe 'ceph::pool' do it { should contain_exec('create-volumes').with( - 'command' => "/bin/true # comment to satisfy puppet syntax requirements\nset -ex\nceph osd pool create volumes 3" + :command => 'ceph osd pool create volumes 3', + :path => ['/bin', '/usr/bin'], ) should contain_exec('set-volumes-pg_num').with( - 'command' => "/bin/true # comment to satisfy puppet syntax requirements\nset -ex\nceph osd pool set volumes pg_num 3" + :command => 'ceph osd pool set volumes pg_num 3', + :path => ['/bin', '/usr/bin'], ) should contain_exec('set-volumes-pgp_num').with( - 'command' => "/bin/true # comment to satisfy puppet syntax requirements\nset -ex\nceph osd pool set volumes pgp_num 4" + :command => 'ceph osd pool set volumes pgp_num 4', + :path => ['/bin', '/usr/bin'], ).that_requires('Exec[set-volumes-pg_num]') should contain_exec('set-volumes-size').with( - 'command' => "/bin/true # comment to satisfy puppet syntax requirements\nset -ex\nceph osd pool set volumes size 2" + :command => 'ceph osd pool set volumes size 2', + :path => ['/bin', '/usr/bin'], ) should contain_exec('set-volumes-tag').with( - 'command' => "/bin/true # comment to satisfy puppet syntax requirements\nset -ex\nceph osd pool application enable volumes rbd" + :command => 'ceph osd pool application enable volumes rbd', + :path => ['/bin', '/usr/bin'], ) should_not contain_exec('delete-volumes') } @@ -69,7 +74,8 @@ describe 'ceph::pool' do it { should_not contain_exec('create-volumes') should contain_exec('delete-volumes').with( - 'command' => "/bin/true # comment to satisfy puppet syntax requirements\nset -ex\nceph osd pool delete volumes volumes --yes-i-really-really-mean-it" + :command => 'ceph osd pool delete volumes volumes --yes-i-really-really-mean-it', + :path => ['/bin', '/usr/bin'], ) } end