Skip to content

Add Server Instance Feature #1450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
extend systemd define to handle instance systemd files
  • Loading branch information
SimonHoenscheid committed Sep 27, 2023
commit 5b829f4423ffb6e6fc250227c20f263f3ac47a15
13 changes: 6 additions & 7 deletions manifests/server/instance/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,11 @@
notify => Class['postgresql::server::reload'],
}
}
# RHEL based systems and Gentoo need variables set for $PGPORT, $DATA_DIR or $PGDATA via a drop-in file
if $facts['os']['family'] == 'RedHat' or ($facts['os']['family'] == 'Gentoo' and $facts['service_provider'] == 'systemd') {
postgresql::server::instance::systemd { $service_name:
port => $port,
datadir => $datadir,
extra_systemd_config => $extra_systemd_config,
}

postgresql::server::instance::systemd { $name:
port => $port,
datadir => $datadir,
extra_systemd_config => $extra_systemd_config,
service_name => $service_name,
}
}
42 changes: 26 additions & 16 deletions manifests/server/instance/systemd.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,36 @@
define postgresql::server::instance::systemd (
Stdlib::Port $port,
Stdlib::Absolutepath $datadir,
String[1] $instance_name = $name,
Optional[String[1]] $extra_systemd_config = undef,
String[1] $service_name = $name,
Enum[present, absent] $drop_in_ensure = 'present',
) {
# Template uses:
# - $port
# - $datadir
# - $extra_systemd_config
systemd::dropin_file { "${service_name}.conf":
ensure => $drop_in_ensure,
unit => "${service_name}.service",
owner => 'root',
group => 'root',
content => epp('postgresql/systemd-override.conf.epp', {
port => $port,
datadir => $datadir,
extra_systemd_config => $extra_systemd_config,
if $facts['service_provider'] == 'systemd' {
if $facts['os']['family'] in ['RedHat', 'Gentoo'] {
# RHEL 7 and 8 both support drop-in files for systemd units.
# Gentoo also supports drop-in files.
# RHEL based Systems need Variables set for $PGPORT, $DATA_DIR or $PGDATA, thats what the drop-in file is for.
# For additional instances (!= 'main') we need a new systemd service anyhow and use one systemd-file. no dropin needed.
#
# Template uses:
# - $port
# - $datadir
# - $extra_systemd_config
systemd::dropin_file { "${service_name}.conf":
ensure => $drop_in_ensure,
unit => "${service_name}.service",
owner => 'root',
group => 'root',
content => epp('postgresql/systemd-override.conf.epp', {
port => $port,
datadir => $datadir,
extra_systemd_config => $extra_systemd_config,
}
),
notify => Class['postgresql::server::service'],
before => Class['postgresql::server::reload'],
}
),
notify => Class['postgresql::server::service'],
before => Class['postgresql::server::reload'],
}
}
}