Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions manifests/server/config_entry.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
# @param value Defines the value for the setting.
# @param path Path for postgresql.conf
# @param comment Defines the comment for the setting. The # is added by default.
# @param instance_name The name of the instance.
#
define postgresql::server::config_entry (
Enum['present', 'absent'] $ensure = 'present',
String[1] $key = $name,
Optional[Variant[String[1], Numeric, Array[String[1]]]] $value = undef,
Stdlib::Absolutepath $path = $postgresql::server::postgresql_conf_path,
Optional[String[1]] $comment = undef,
String[1] $instance_name = 'main',
) {
# Those are the variables that are marked as "(change requires restart)"
# on postgresql.conf. Items are ordered as on postgresql.conf.
Expand Down Expand Up @@ -72,15 +74,15 @@
versioncmp($postgresql::server::_version, $requires_restart_until[$key]) < 0
)) {
Postgresql_conf {
notify => Class['postgresql::server::reload'],
notify => Postgresql::Server::Instance::Reload[$instance_name],
}
} elsif $postgresql::server::service_restart_on_change {
Postgresql_conf {
notify => Class['postgresql::server::service'],
notify => Postgresql::Server::Instance::Service[$instance_name],
}
} else {
Postgresql_conf {
before => Class['postgresql::server::service'],
before => Postgresql::Server::Instance::Service[$instance_name],
}
}

Expand All @@ -90,6 +92,6 @@
key => $key,
value => $value,
comment => $comment,
require => Class['postgresql::server::initdb'],
require => Postgresql::Server::Instance::Initdb[$instance_name],
}
}
2 changes: 1 addition & 1 deletion manifests/server/database.pp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
postgresql_psql { "CREATE DATABASE \"${dbname}\"":
command => "CREATE DATABASE \"${dbname}\" WITH ${template_option} ${encoding_option} ${locale_option} ${tablespace_option}",
unless => "SELECT 1 FROM pg_database WHERE datname = '${dbname}'",
require => Class['postgresql::server::service'],
require => Postgresql::Server::Instance::Service[$instance],
}

# This will prevent users from connecting to the database unless they've been
Expand Down
4 changes: 2 additions & 2 deletions manifests/server/instance/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
group => $group,
mode => '0640',
warn => true,
notify => Class['postgresql::server::reload'],
notify => Postgresql::Server::Instance::Reload[$name],
}

if $pg_hba_conf_defaults {
Expand Down Expand Up @@ -249,7 +249,7 @@
group => $group,
mode => '0640',
warn => true,
notify => Class['postgresql::server::reload'],
notify => Postgresql::Server::Instance::Reload[$name],
}
}

Expand Down
2 changes: 1 addition & 1 deletion manifests/server/instance/reload.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
command => $service_reload,
onlyif => $service_status,
refreshonly => true,
require => Class['postgresql::server::service'],
require => Postgresql::Server::Instance::Service[$name],
}
}
4 changes: 2 additions & 2 deletions manifests/server/instance/systemd.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
extra_systemd_config => $extra_systemd_config,
}
),
notify => Class['postgresql::server::service'],
before => Class['postgresql::server::reload'],
notify => Postgresql::Server::Instance::Service[$name],
before => Postgresql::Server::Instance::Reload[$name],
}
}
}
Expand Down
15 changes: 10 additions & 5 deletions manifests/server_instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
port => $config_settings['port'],
user => $instance_user,
}
postgresql::server::instance::reload { $instance_name:
service_status => $service_settings['service_status'],
service_reload => "systemctl reload ${service_settings['service_name']}.service",
}
postgresql::server::instance::passwd { $instance_name:
* => $passwd_settings,
}
Expand All @@ -84,11 +88,12 @@
$value = $settings['value']
$comment = $settings['comment']
postgresql::server::config_entry { "${entry}_${$instance_name}":
ensure => bool2str($value =~ Undef, 'absent', 'present'),
key => $entry,
value => $value,
comment => $comment,
path => $config_settings['postgresql_conf_path'],
ensure => bool2str($value =~ Undef, 'absent', 'present'),
key => $entry,
value => $value,
comment => $comment,
path => $config_settings['postgresql_conf_path'],
instance_name => $instance_name,
}
}
$pg_hba_rules.each |String[1] $rule_name, Postgresql::Pg_hba_rule $rule| {
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class { 'postgresql::globals':
it { is_expected.to contain_class('postgresql::server') }

it {
expect(subject).to contain_Postgresql_conf('data_directory_for_instance_main').that_notifies('Class[postgresql::server::service]')
expect(subject).to contain_Postgresql_conf('data_directory_for_instance_main').that_notifies('Postgresql::Server::Instance::Service[main]')
}

it { is_expected.to contain_postgresql__server__config_entry('data_directory_for_instance_main') }
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/server/config_entry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
expect(subject).to contain_postgresql_conf('unix_socket_directories')
.with(name: 'unix_socket_directories',
value: '/var/pgsql, /opt/postgresql, /root/')
.that_notifies('Class[postgresql::server::service]')
.that_notifies('Postgresql::Server::Instance::Service[main]')
end
end
end