|
5 | 5 | define postgresql::server::instance::systemd (
|
6 | 6 | Stdlib::Port $port,
|
7 | 7 | Stdlib::Absolutepath $datadir,
|
| 8 | + String[1] $instance_name = $name, |
8 | 9 | Optional[String[1]] $extra_systemd_config = undef,
|
9 | 10 | String[1] $service_name = $name,
|
10 | 11 | Enum[present, absent] $drop_in_ensure = 'present',
|
11 | 12 | ) {
|
12 |
| - # Template uses: |
13 |
| - # - $port |
14 |
| - # - $datadir |
15 |
| - # - $extra_systemd_config |
16 |
| - systemd::dropin_file { "${service_name}.conf": |
17 |
| - ensure => $drop_in_ensure, |
18 |
| - unit => "${service_name}.service", |
19 |
| - owner => 'root', |
20 |
| - group => 'root', |
21 |
| - content => epp('postgresql/systemd-override.conf.epp', { |
22 |
| - port => $port, |
23 |
| - datadir => $datadir, |
24 |
| - extra_systemd_config => $extra_systemd_config, |
| 13 | + if $facts['service_provider'] == 'systemd' { |
| 14 | + if $facts['os']['family'] in ['RedHat', 'Gentoo'] { |
| 15 | + # RHEL 7 and 8 both support drop-in files for systemd units. |
| 16 | + # Gentoo also supports drop-in files. |
| 17 | + # RHEL based Systems need Variables set for $PGPORT, $DATA_DIR or $PGDATA, thats what the drop-in file is for. |
| 18 | + # For additional instances (!= 'main') we need a new systemd service anyhow and use one systemd-file. no dropin needed. |
| 19 | + # |
| 20 | + # Template uses: |
| 21 | + # - $port |
| 22 | + # - $datadir |
| 23 | + # - $extra_systemd_config |
| 24 | + systemd::dropin_file { "${service_name}.conf": |
| 25 | + ensure => $drop_in_ensure, |
| 26 | + unit => "${service_name}.service", |
| 27 | + owner => 'root', |
| 28 | + group => 'root', |
| 29 | + content => epp('postgresql/systemd-override.conf.epp', { |
| 30 | + port => $port, |
| 31 | + datadir => $datadir, |
| 32 | + extra_systemd_config => $extra_systemd_config, |
| 33 | + } |
| 34 | + ), |
| 35 | + notify => Class['postgresql::server::service'], |
| 36 | + before => Class['postgresql::server::reload'], |
25 | 37 | }
|
26 |
| - ), |
27 |
| - notify => Class['postgresql::server::service'], |
28 |
| - before => Class['postgresql::server::reload'], |
| 38 | + } |
29 | 39 | }
|
30 | 40 | }
|
0 commit comments