Add environment param to service_validation.pp
To be able to pass OS_PASSWORD=, we need the environment param to be added to this class. Needed-By: I8ab8a2c7bb1d93d6fb9d16eabd3a1112b1e1237b Change-Id: If10b57a38c61cadca48e1e3c1e76d659397849fb
This commit is contained in:
parent
56dba5e68c
commit
78c08ad6dc
@ -61,6 +61,10 @@
|
||||
# Run the exec if all conditions in the array return false.
|
||||
# string or array; optional; default to 'undef'
|
||||
#
|
||||
# [*environment*]
|
||||
# Environment to use
|
||||
# string; optional; default to empty array
|
||||
#
|
||||
define openstacklib::service_validation(
|
||||
$command,
|
||||
$service_name = $name,
|
||||
@ -72,6 +76,7 @@ define openstacklib::service_validation(
|
||||
$try_sleep = '2',
|
||||
$onlyif = undef,
|
||||
$unless = undef,
|
||||
$environment = [],
|
||||
) {
|
||||
|
||||
if $onlyif and $unless {
|
||||
@ -80,6 +85,7 @@ define openstacklib::service_validation(
|
||||
|
||||
exec { "execute ${service_name} validation":
|
||||
command => $command,
|
||||
environment => $environment,
|
||||
path => $path,
|
||||
provider => $provider,
|
||||
refreshonly => $refreshonly,
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
There's a new environment variable for service-validation. With it, it is
|
||||
possible to pass in things like OS_PASWORD which should never appear in
|
||||
the command line.
|
@ -36,13 +36,13 @@ describe 'openstacklib::service_validation' do
|
||||
:path => '/usr/bin:/bin:/usr/sbin:/sbin',
|
||||
:provider => 'shell',
|
||||
:command => 'nova list',
|
||||
:environment => [],
|
||||
:refreshonly => false,
|
||||
:timeout => '60',
|
||||
:tries => '10',
|
||||
:try_sleep => '2',
|
||||
:logoutput => 'on_failure',
|
||||
)}
|
||||
|
||||
end
|
||||
|
||||
context 'with unless parameter' do
|
||||
@ -60,12 +60,11 @@ describe 'openstacklib::service_validation' do
|
||||
:try_sleep => '2',
|
||||
:unless => 'pwd',
|
||||
)}
|
||||
|
||||
end
|
||||
|
||||
context 'with onlyif parameter' do
|
||||
let :params do
|
||||
required_params.merge!({:onlyif => 'pwd' })
|
||||
required_params.merge!({ :onlyif => 'pwd' })
|
||||
end
|
||||
|
||||
it { is_expected.to contain_exec("execute #{title} validation").with(
|
||||
@ -78,13 +77,23 @@ describe 'openstacklib::service_validation' do
|
||||
:try_sleep => '2',
|
||||
:onlyif => 'pwd',
|
||||
)}
|
||||
end
|
||||
|
||||
context 'with environment parameter' do
|
||||
let :params do
|
||||
required_params.merge!({ :environment => ['OS_PASSWORD=secret'] })
|
||||
end
|
||||
|
||||
it { is_expected.to contain_exec("execute #{title} validation").with(
|
||||
:environment => ['OS_PASSWORD=secret'],
|
||||
)}
|
||||
end
|
||||
|
||||
context 'when omitting a required parameter command' do
|
||||
let :params do
|
||||
required_params.delete(:command)
|
||||
end
|
||||
|
||||
it { expect { is_expected.to raise_error(Puppet::Error) } }
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user