Skip to content

Commit

Permalink
Merge pull request #1167 from puppetlabs/ensure_value
Browse files Browse the repository at this point in the history
service_ensure => true is now an allowed value (aliased to running)
  • Loading branch information
sanfrancrisko committed Apr 30, 2020
2 parents 22bf0bc + e4bac1c commit 07a868e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion manifests/server/service.pp
Expand Up @@ -25,7 +25,7 @@
status => $service_status,
}

if $service_ensure == 'running' {
if $service_ensure in ['running', true] {
# This blocks the class before continuing if chained correctly, making
# sure the service really is 'up' before continuing.
#
Expand Down
22 changes: 22 additions & 0 deletions spec/unit/classes/server_spec.rb
Expand Up @@ -57,6 +57,28 @@
end
end

describe 'service_ensure => true' do
let(:params) do
{
service_ensure: true,
postgres_password: 'new-p@s$word-to-set',
}
end

it { is_expected.to contain_class('postgresql::params') }
it { is_expected.to contain_class('postgresql::server') }
it { is_expected.to contain_class('postgresql::server::passwd') }
it 'validates connection' do
is_expected.to contain_postgresql_conn_validator('validate_service_is_running')
end
it 'sets postgres password' do
is_expected.to contain_exec('set_postgres_postgrespw').with('command' => '/usr/bin/psql -c "ALTER ROLE \"postgres\" PASSWORD ${NEWPASSWD_ESCAPED}"',
'user' => 'postgres',
'environment' => ['PGPASSWORD=new-p@s$word-to-set', 'PGPORT=5432', 'NEWPASSWD_ESCAPED=$$new-p@s$word-to-set$$'],
'unless' => "/usr/bin/psql -h localhost -p 5432 -c 'select 1' > /dev/null")
end
end

describe 'service_ensure => stopped' do
let(:params) { { service_ensure: 'stopped' } }

Expand Down

0 comments on commit 07a868e

Please sign in to comment.