Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
puppet: Use Service for PostgreSQL restarts.
Alex Vandiver7a8a8f5f2306
diff --git a/puppet/kandra/manifests/profile/postgresql.pp b/puppet/kandra/manifests/profile/postgresql.ppindex f1ef073250d..bbfa443174a 100644--- a/puppet/kandra/manifests/profile/postgresql.pp+++ b/puppet/kandra/manifests/profile/postgresql.pp@@ -1,9 +1,14 @@class kandra::profile::postgresql inherits kandra::profile::base {-- include zulip::profile::postgresqlinclude kandra::teleport::dbinclude kandra::prometheus::postgresql+ # We key off of `listen_addresses` being set to know if we should be starting PostgreSQL.+ $listen_addresses = zulipconf('postgresql', 'listen_addresses', undef)+ $is_stage1 = ($listen_addresses == undef)+ class { 'zulip::profile::postgresql':+ start => ! $is_stage1,+ }+package { ['xfsprogs', 'nvme-cli']: ensure => installed }kandra::firewall_allow{ 'postgresql': }@@ -35,30 +40,32 @@ class kandra::profile::postgresql inherits kandra::profile::base {}# This is the second stage, after secrets are configured- $replication_primary = zulipconf('postgresql', 'replication_primary', undef)- $replication_user = zulipconf('postgresql', 'replication_user', undef)- if $replication_primary != undef and $replication_user != undef {- file { '/root/setup_data.sh':- ensure => file,- owner => 'root',- group => 'root',- mode => '0744',- source => 'puppet:///modules/kandra/postgresql/setup_data.sh',- }- exec { 'setup_data':- command => '/root/setup_data.sh',- require => [File['/usr/local/bin/env-wal-g'], Exec['setup_disks']],- unless => "test -d /srv/data/postgresql/${zulip::postgresql_common::version}/main",- timeout => 0,- before => File["${zulip::postgresql_base::postgresql_datadir}/standby.signal"],- notify => Exec[$zulip::postgresql_base::postgresql_restart],+ if (! $is_stage1) {+ $replication_primary = zulipconf('postgresql', 'replication_primary', undef)+ $replication_user = zulipconf('postgresql', 'replication_user', undef)+ if $replication_primary != undef and $replication_user != undef {+ file { '/root/setup_data.sh':+ ensure => file,+ owner => 'root',+ group => 'root',+ mode => '0744',+ source => 'puppet:///modules/kandra/postgresql/setup_data.sh',+ }+ exec { 'setup_data':+ command => '/root/setup_data.sh',+ require => [File['/usr/local/bin/env-wal-g'], Exec['setup_disks']],+ unless => "test -d /srv/data/postgresql/${zulip::postgresql_common::version}/main",+ timeout => 0,+ before => File["${zulip::postgresql_base::postgresql_datadir}/standby.signal"],+ notify => Service['postgresql'],+ }}}file { "${zulip::postgresql_base::postgresql_confdir}/pg_hba.conf":ensure => file,require => Package["postgresql-${zulip::postgresql_common::version}"],- notify => Exec[$zulip::postgresql_base::postgresql_restart],+ notify => Service['postgresql'],owner => 'postgres',group => 'postgres',mode => '0640',diff --git a/puppet/zulip/manifests/postgresql_base.pp b/puppet/zulip/manifests/postgresql_base.ppindex efcedca376b..21c188dc477 100644--- a/puppet/zulip/manifests/postgresql_base.pp+++ b/puppet/zulip/manifests/postgresql_base.pp@@ -16,7 +16,6 @@ class zulip::postgresql_base {$tsearch_datadir = "${postgresql_sharedir}/tsearch_data"$pgroonga_setup_sql_path = "${postgresql_sharedir}/pgroonga_setup.sql"$setup_system_deps = 'setup_apt_repo'- $postgresql_restart = "pg_ctlcluster ${zulip::postgresql_common::version} main restart"}'RedHat': {$postgresql = "postgresql${zulip::postgresql_common::version}"@@ -30,7 +29,6 @@ class zulip::postgresql_base {$tsearch_datadir = "${postgresql_sharedir}/tsearch_data/"$pgroonga_setup_sql_path = "${postgresql_sharedir}/pgroonga_setup.sql"$setup_system_deps = 'setup_yum_repo'- $postgresql_restart = "systemctl restart postgresql-${zulip::postgresql_common::version}"}default: {fail('osfamily not supported')diff --git a/puppet/zulip/manifests/profile/postgresql.pp b/puppet/zulip/manifests/profile/postgresql.ppindex 04ca359f302..b288c1f6800 100644--- a/puppet/zulip/manifests/profile/postgresql.pp+++ b/puppet/zulip/manifests/profile/postgresql.pp@@ -1,5 +1,5 @@# @summary Extends postgresql_base by tuning the configuration.-class zulip::profile::postgresql {+class zulip::profile::postgresql(Boolean $start = true) {include zulip::profile::baseinclude zulip::postgresql_base@@ -73,7 +73,7 @@ class zulip::profile::postgresql {file { "${zulip::postgresql_base::postgresql_datadir}/standby.signal":ensure => file,require => Package[$zulip::postgresql_base::postgresql],- before => Exec[$zulip::postgresql_base::postgresql_restart],+ before => Service['postgresql'],owner => 'postgres',group => 'postgres',mode => '0644',@@ -88,10 +88,9 @@ class zulip::profile::postgresql {} else {$require = [Package[$zulip::postgresql_base::postgresql]]}- exec { $zulip::postgresql_base::postgresql_restart:- require => $require,- refreshonly => true,- subscribe => [ File[$postgresql_conf_file] ],- onlyif => "test -d ${zulip::postgresql_base::postgresql_datadir}",+ service { 'postgresql':+ ensure => $start,+ require => $require,+ subscribe => [ File[$postgresql_conf_file] ],}}