Add service_manage parameter
Loosely addresses MODULES-1522
This commit is contained in:
parent
61f86551d8
commit
789543fc45
5 changed files with 45 additions and 23 deletions
|
@ -393,6 +393,9 @@ Value to pass through to the `package` resource when creating the server instanc
|
||||||
####`plperl_package_name`
|
####`plperl_package_name`
|
||||||
This sets the default package name for the PL/Perl extension. Defaults to utilising the operating system default.
|
This sets the default package name for the PL/Perl extension. Defaults to utilising the operating system default.
|
||||||
|
|
||||||
|
####`service_manage`
|
||||||
|
This setting selects whether Puppet should manage the service. Defaults to `true`.
|
||||||
|
|
||||||
####`service_name`
|
####`service_name`
|
||||||
This setting can be used to override the default postgresql service name. If not specified, the module will use whatever service name is the default for your OS distro.
|
This setting can be used to override the default postgresql service name. If not specified, the module will use whatever service name is the default for your OS distro.
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ class postgresql::params inherits postgresql::globals {
|
||||||
$locale = $locale
|
$locale = $locale
|
||||||
$service_ensure = 'running'
|
$service_ensure = 'running'
|
||||||
$service_enable = true
|
$service_enable = true
|
||||||
|
$service_manage = true
|
||||||
$service_provider = $service_provider
|
$service_provider = $service_provider
|
||||||
$manage_pg_hba_conf = pick($manage_pg_hba_conf, true)
|
$manage_pg_hba_conf = pick($manage_pg_hba_conf, true)
|
||||||
$manage_pg_ident_conf = pick($manage_pg_ident_conf, true)
|
$manage_pg_ident_conf = pick($manage_pg_ident_conf, true)
|
||||||
|
|
|
@ -10,6 +10,7 @@ class postgresql::server (
|
||||||
|
|
||||||
$service_ensure = $postgresql::params::service_ensure,
|
$service_ensure = $postgresql::params::service_ensure,
|
||||||
$service_enable = $postgresql::params::service_enable,
|
$service_enable = $postgresql::params::service_enable,
|
||||||
|
$service_manage = $postgresql::params::service_manage,
|
||||||
$service_name = $postgresql::params::service_name,
|
$service_name = $postgresql::params::service_name,
|
||||||
$service_provider = $postgresql::params::service_provider,
|
$service_provider = $postgresql::params::service_provider,
|
||||||
$service_status = $postgresql::params::service_status,
|
$service_status = $postgresql::params::service_status,
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
class postgresql::server::service {
|
class postgresql::server::service {
|
||||||
$service_ensure = $postgresql::server::service_ensure
|
$service_ensure = $postgresql::server::service_ensure
|
||||||
$service_enable = $postgresql::server::service_enable
|
$service_enable = $postgresql::server::service_enable
|
||||||
|
$service_manage = $postgresql::server::service_manage
|
||||||
$service_name = $postgresql::server::service_name
|
$service_name = $postgresql::server::service_name
|
||||||
$service_provider = $postgresql::server::service_provider
|
$service_provider = $postgresql::server::service_provider
|
||||||
$service_status = $postgresql::server::service_status
|
$service_status = $postgresql::server::service_status
|
||||||
|
@ -11,30 +12,33 @@ class postgresql::server::service {
|
||||||
|
|
||||||
anchor { 'postgresql::server::service::begin': }
|
anchor { 'postgresql::server::service::begin': }
|
||||||
|
|
||||||
service { 'postgresqld':
|
if $service_manage {
|
||||||
ensure => $service_ensure,
|
|
||||||
enable => $service_enable,
|
|
||||||
name => $service_name,
|
|
||||||
provider => $service_provider,
|
|
||||||
hasstatus => true,
|
|
||||||
status => $service_status,
|
|
||||||
}
|
|
||||||
|
|
||||||
if $service_ensure == 'running' {
|
service { 'postgresqld':
|
||||||
# This blocks the class before continuing if chained correctly, making
|
ensure => $service_ensure,
|
||||||
# sure the service really is 'up' before continuing.
|
enable => $service_enable,
|
||||||
#
|
name => $service_name,
|
||||||
# Without it, we may continue doing more work before the database is
|
provider => $service_provider,
|
||||||
# prepared leading to a nasty race condition.
|
hasstatus => true,
|
||||||
postgresql::validate_db_connection { 'validate_service_is_running':
|
status => $service_status,
|
||||||
run_as => $user,
|
}
|
||||||
database_name => $default_database,
|
|
||||||
database_port => $port,
|
if $service_ensure == 'running' {
|
||||||
sleep => 1,
|
# This blocks the class before continuing if chained correctly, making
|
||||||
tries => 60,
|
# sure the service really is 'up' before continuing.
|
||||||
create_db_first => false,
|
#
|
||||||
require => Service['postgresqld'],
|
# Without it, we may continue doing more work before the database is
|
||||||
before => Anchor['postgresql::server::service::end']
|
# prepared leading to a nasty race condition.
|
||||||
|
postgresql::validate_db_connection { 'validate_service_is_running':
|
||||||
|
run_as => $user,
|
||||||
|
database_name => $default_database,
|
||||||
|
database_port => $port,
|
||||||
|
sleep => 1,
|
||||||
|
tries => 60,
|
||||||
|
create_db_first => false,
|
||||||
|
require => Service['postgresqld'],
|
||||||
|
before => Anchor['postgresql::server::service::end']
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,19 @@ describe 'postgresql::server', :type => :class do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'service_manage => true' do
|
||||||
|
let(:params) {{ :service_manage => true }}
|
||||||
|
it { is_expected.to contain_service('postgresqld') }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'service_manage => false' do
|
||||||
|
let(:params) {{ :service_manage => false }}
|
||||||
|
it { is_expected.not_to contain_service('postgresqld') }
|
||||||
|
it 'shouldnt validate connection' do
|
||||||
|
is_expected.not_to contain_postgresql__validate_db_connection('validate_service_is_running')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'package_ensure => absent' do
|
describe 'package_ensure => absent' do
|
||||||
let(:params) do
|
let(:params) do
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue