Skip to content

Commit

Permalink
fix service reload/restart for correct instance in server_instance/se…
Browse files Browse the repository at this point in the history
…rver::config_entry define
  • Loading branch information
SimonHoenscheid committed Apr 3, 2024
1 parent a97a58f commit 994aa8e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
9 changes: 5 additions & 4 deletions manifests/server/config_entry.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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',

Check warning on line 15 in manifests/server/config_entry.pp

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)

missing documentation for defined type parameter postgresql::server::config_entry::instance_name (check: parameter_documentation)

Check warning on line 15 in manifests/server/config_entry.pp

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)

missing documentation for defined type parameter postgresql::server::config_entry::instance_name (check: parameter_documentation)

Check warning on line 15 in manifests/server/config_entry.pp

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)

missing documentation for defined type parameter postgresql::server::config_entry::instance_name (check: parameter_documentation)

Check warning on line 15 in manifests/server/config_entry.pp

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)

missing documentation for defined type parameter postgresql::server::config_entry::instance_name (check: parameter_documentation)
) {
# 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 +73,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 +91,6 @@
key => $key,
value => $value,
comment => $comment,
require => Class['postgresql::server::initdb'],
require => Postgresql::Server::Instance::Initdb[$instance_name],
}
}
11 changes: 6 additions & 5 deletions manifests/server_instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -88,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

0 comments on commit 994aa8e

Please sign in to comment.