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:

committed by
Tobias Urdin

parent
56dba5e68c
commit
78c08ad6dc
@@ -61,6 +61,10 @@
|
|||||||
# Run the exec if all conditions in the array return false.
|
# Run the exec if all conditions in the array return false.
|
||||||
# string or array; optional; default to 'undef'
|
# string or array; optional; default to 'undef'
|
||||||
#
|
#
|
||||||
|
# [*environment*]
|
||||||
|
# Environment to use
|
||||||
|
# string; optional; default to empty array
|
||||||
|
#
|
||||||
define openstacklib::service_validation(
|
define openstacklib::service_validation(
|
||||||
$command,
|
$command,
|
||||||
$service_name = $name,
|
$service_name = $name,
|
||||||
@@ -72,6 +76,7 @@ define openstacklib::service_validation(
|
|||||||
$try_sleep = '2',
|
$try_sleep = '2',
|
||||||
$onlyif = undef,
|
$onlyif = undef,
|
||||||
$unless = undef,
|
$unless = undef,
|
||||||
|
$environment = [],
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if $onlyif and $unless {
|
if $onlyif and $unless {
|
||||||
@@ -80,6 +85,7 @@ define openstacklib::service_validation(
|
|||||||
|
|
||||||
exec { "execute ${service_name} validation":
|
exec { "execute ${service_name} validation":
|
||||||
command => $command,
|
command => $command,
|
||||||
|
environment => $environment,
|
||||||
path => $path,
|
path => $path,
|
||||||
provider => $provider,
|
provider => $provider,
|
||||||
refreshonly => $refreshonly,
|
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',
|
:path => '/usr/bin:/bin:/usr/sbin:/sbin',
|
||||||
:provider => 'shell',
|
:provider => 'shell',
|
||||||
:command => 'nova list',
|
:command => 'nova list',
|
||||||
|
:environment => [],
|
||||||
:refreshonly => false,
|
:refreshonly => false,
|
||||||
:timeout => '60',
|
:timeout => '60',
|
||||||
:tries => '10',
|
:tries => '10',
|
||||||
:try_sleep => '2',
|
:try_sleep => '2',
|
||||||
:logoutput => 'on_failure',
|
:logoutput => 'on_failure',
|
||||||
)}
|
)}
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with unless parameter' do
|
context 'with unless parameter' do
|
||||||
@@ -60,12 +60,11 @@ describe 'openstacklib::service_validation' do
|
|||||||
:try_sleep => '2',
|
:try_sleep => '2',
|
||||||
:unless => 'pwd',
|
:unless => 'pwd',
|
||||||
)}
|
)}
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with onlyif parameter' do
|
context 'with onlyif parameter' do
|
||||||
let :params do
|
let :params do
|
||||||
required_params.merge!({:onlyif => 'pwd' })
|
required_params.merge!({ :onlyif => 'pwd' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to contain_exec("execute #{title} validation").with(
|
it { is_expected.to contain_exec("execute #{title} validation").with(
|
||||||
@@ -78,13 +77,23 @@ describe 'openstacklib::service_validation' do
|
|||||||
:try_sleep => '2',
|
:try_sleep => '2',
|
||||||
:onlyif => 'pwd',
|
: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
|
end
|
||||||
|
|
||||||
context 'when omitting a required parameter command' do
|
context 'when omitting a required parameter command' do
|
||||||
let :params do
|
let :params do
|
||||||
required_params.delete(:command)
|
required_params.delete(:command)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect { is_expected.to raise_error(Puppet::Error) } }
|
it { expect { is_expected.to raise_error(Puppet::Error) } }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user