Get rid of script workaround for single command calls

... to simplify the command called by the exec resources.

Change-Id: Ib7942c0795532bfe4448225fe64767dcebf1a537
This commit is contained in:
Takashi Kajinami 2024-01-09 21:23:52 +09:00
parent 67888b7f3c
commit db8e683898
4 changed files with 36 additions and 50 deletions

View File

@ -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,
}
}

View File

@ -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 |>

View File

@ -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

View File

@ -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