From 16c4cea951aeab2ffeed89304884b2e1029c7bd4 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Thu, 11 Jun 2020 19:52:33 -0700 Subject: [PATCH] puppet: Pull postgres config directory into postgres_appdb_base. As the previous commit, this is currently only used in tuning, but is a property of the whole postgres configuration; move it there, as just the directory, not the file. Use this directory consistently in the erb templates. Since we produce a `pg_hba.conf`, it makes sense that we point to the path that we know that we explicitly wrote to, for instance. --- puppet/zulip/manifests/postgres_appdb_base.pp | 2 ++ puppet/zulip/manifests/postgres_appdb_tuned.pp | 9 +++------ .../postgresql/10/postgresql.conf.centos.template.erb | 4 ++-- .../templates/postgresql/10/postgresql.conf.template.erb | 4 ++-- .../templates/postgresql/11/postgresql.conf.template.erb | 4 ++-- .../templates/postgresql/12/postgresql.conf.template.erb | 4 ++-- .../postgresql/9.3/postgresql.conf.template.erb | 4 ++-- .../postgresql/9.5/postgresql.conf.template.erb | 4 ++-- .../postgresql/9.6/postgresql.conf.template.erb | 4 ++-- puppet/zulip_ops/manifests/postgres_appdb.pp | 2 +- puppet/zulip_ops/manifests/postgres_slave.pp | 2 +- 11 files changed, 21 insertions(+), 22 deletions(-) diff --git a/puppet/zulip/manifests/postgres_appdb_base.pp b/puppet/zulip/manifests/postgres_appdb_base.pp index 2eb138c216..2a0b95d11e 100644 --- a/puppet/zulip/manifests/postgres_appdb_base.pp +++ b/puppet/zulip/manifests/postgres_appdb_base.pp @@ -9,6 +9,7 @@ class zulip::postgres_appdb_base { include zulip::apt_repository $postgresql = "postgresql-${zulip::base::postgres_version}" $postgres_sharedir = "/usr/share/postgresql/${zulip::base::postgres_version}" + $postgres_confdir = "/etc/postgresql/${zulip::base::postgres_version}/main" $tsearch_datadir = "${postgres_sharedir}/tsearch_data" $pgroonga_setup_sql_path = "${postgres_sharedir}/pgroonga_setup.sql" $setup_system_deps = 'setup_apt_repo' @@ -18,6 +19,7 @@ class zulip::postgres_appdb_base { include zulip::yum_repository $postgresql = "postgresql${zulip::base::postgres_version}" $postgres_sharedir = "/usr/pgsql-${zulip::base::postgres_version}/share" + $postgres_confdir = "/var/lib/pgsql/${zulip::base::postgres_version}/data" $tsearch_datadir = "${postgres_sharedir}/tsearch_data/" $pgroonga_setup_sql_path = "${postgres_sharedir}/pgroonga_setup.sql" $setup_system_deps = 'setup_yum_repo' diff --git a/puppet/zulip/manifests/postgres_appdb_tuned.pp b/puppet/zulip/manifests/postgres_appdb_tuned.pp index d2cb7216e4..aa50f86434 100644 --- a/puppet/zulip/manifests/postgres_appdb_tuned.pp +++ b/puppet/zulip/manifests/postgres_appdb_tuned.pp @@ -3,10 +3,6 @@ class zulip::postgres_appdb_tuned { include zulip::postgres_appdb_base - $postgres_conf = $::osfamily ? { - 'debian' => "/etc/postgresql/${zulip::base::postgres_version}/main/postgresql.conf", - 'redhat' => "/var/lib/pgsql/${zulip::base::postgres_version}/data/postgresql.conf", - } $work_mem = $zulip::base::total_memory_mb / 512 $shared_buffers = $zulip::base::total_memory_mb / 8 $effective_cache_size = $zulip::base::total_memory_mb * 10 / 32 @@ -24,7 +20,8 @@ class zulip::postgres_appdb_tuned { # Only used in CentOS for now $pg_datadir = "/var/lib/pgsql/${zulip::base::postgres_version}/data" - file { $postgres_conf: + $postgres_conf_file = "${zulip::postgres_appdb_base::postgres_confdir}/postgresql.conf" + file { $postgres_conf_file: ensure => file, require => Package[$zulip::postgres_appdb_base::postgresql], owner => 'postgres', @@ -36,6 +33,6 @@ class zulip::postgres_appdb_tuned { exec { $zulip::postgres_appdb_base::postgres_restart: require => Package[$zulip::postgres_appdb_base::postgresql], refreshonly => true, - subscribe => [ File[$postgres_conf] ] + subscribe => [ File[$postgres_conf_file] ] } } diff --git a/puppet/zulip/templates/postgresql/10/postgresql.conf.centos.template.erb b/puppet/zulip/templates/postgresql/10/postgresql.conf.centos.template.erb index c27c584bbf..cfe5420e54 100644 --- a/puppet/zulip/templates/postgresql/10/postgresql.conf.centos.template.erb +++ b/puppet/zulip/templates/postgresql/10/postgresql.conf.centos.template.erb @@ -40,9 +40,9 @@ data_directory = '<%= scope["zulip::postgres_appdb_tuned::pg_datadir"] %>' # use data in another directory # (change requires restart) -hba_file = '<%= scope["zulip::postgres_appdb_tuned::pg_datadir"] %>/pg_hba.conf' # host-based authentication file +hba_file = '<%= scope["zulip::postgres_appdb_base::postgres_confdir"] %>/pg_hba.conf' # host-based authentication file # (change requires restart) -ident_file = '<%= scope["zulip::postgres_appdb_tuned::pg_datadir"] %>/pg_ident.conf' # ident configuration file +ident_file = '<%= scope["zulip::postgres_appdb_base::postgres_confdir"] %>/pg_ident.conf' # ident configuration file # (change requires restart) # If external_pid_file is not explicitly set, no extra PID file is written. diff --git a/puppet/zulip/templates/postgresql/10/postgresql.conf.template.erb b/puppet/zulip/templates/postgresql/10/postgresql.conf.template.erb index c5d4c7b0a8..50775ca7f3 100644 --- a/puppet/zulip/templates/postgresql/10/postgresql.conf.template.erb +++ b/puppet/zulip/templates/postgresql/10/postgresql.conf.template.erb @@ -40,9 +40,9 @@ data_directory = '/var/lib/postgresql/<%= scope["zulip::base::postgres_version"] %>/main' # use data in another directory # (change requires restart) -hba_file = '/etc/postgresql/<%= scope["zulip::base::postgres_version"] %>/main/pg_hba.conf' # host-based authentication file +hba_file = '<%= scope["zulip::postgres_appdb_base::postgres_confdir"] %>/pg_hba.conf' # host-based authentication file # (change requires restart) -ident_file = '/etc/postgresql/<%= scope["zulip::base::postgres_version"] %>/main/pg_ident.conf' # ident configuration file +ident_file = '<%= scope["zulip::postgres_appdb_base::postgres_confdir"] %>/pg_ident.conf' # ident configuration file # (change requires restart) # If external_pid_file is not explicitly set, no extra PID file is written. diff --git a/puppet/zulip/templates/postgresql/11/postgresql.conf.template.erb b/puppet/zulip/templates/postgresql/11/postgresql.conf.template.erb index c5d4c7b0a8..50775ca7f3 100644 --- a/puppet/zulip/templates/postgresql/11/postgresql.conf.template.erb +++ b/puppet/zulip/templates/postgresql/11/postgresql.conf.template.erb @@ -40,9 +40,9 @@ data_directory = '/var/lib/postgresql/<%= scope["zulip::base::postgres_version"] %>/main' # use data in another directory # (change requires restart) -hba_file = '/etc/postgresql/<%= scope["zulip::base::postgres_version"] %>/main/pg_hba.conf' # host-based authentication file +hba_file = '<%= scope["zulip::postgres_appdb_base::postgres_confdir"] %>/pg_hba.conf' # host-based authentication file # (change requires restart) -ident_file = '/etc/postgresql/<%= scope["zulip::base::postgres_version"] %>/main/pg_ident.conf' # ident configuration file +ident_file = '<%= scope["zulip::postgres_appdb_base::postgres_confdir"] %>/pg_ident.conf' # ident configuration file # (change requires restart) # If external_pid_file is not explicitly set, no extra PID file is written. diff --git a/puppet/zulip/templates/postgresql/12/postgresql.conf.template.erb b/puppet/zulip/templates/postgresql/12/postgresql.conf.template.erb index d9e2ff2e2e..04708bc717 100644 --- a/puppet/zulip/templates/postgresql/12/postgresql.conf.template.erb +++ b/puppet/zulip/templates/postgresql/12/postgresql.conf.template.erb @@ -40,9 +40,9 @@ data_directory = '/var/lib/postgresql/<%= scope["zulip::base::postgres_version"] %>/main' # use data in another directory # (change requires restart) -hba_file = '/etc/postgresql/<%= scope["zulip::base::postgres_version"] %>/main/pg_hba.conf' # host-based authentication file +hba_file = '<%= scope["zulip::postgres_appdb_base::postgres_confdir"] %>/pg_hba.conf' # host-based authentication file # (change requires restart) -ident_file = '/etc/postgresql/<%= scope["zulip::base::postgres_version"] %>/main/pg_ident.conf' # ident configuration file +ident_file = '<%= scope["zulip::postgres_appdb_base::postgres_confdir"] %>/pg_ident.conf' # ident configuration file # (change requires restart) # If external_pid_file is not explicitly set, no extra PID file is written. diff --git a/puppet/zulip/templates/postgresql/9.3/postgresql.conf.template.erb b/puppet/zulip/templates/postgresql/9.3/postgresql.conf.template.erb index 530d7f84e5..6d722e22c1 100644 --- a/puppet/zulip/templates/postgresql/9.3/postgresql.conf.template.erb +++ b/puppet/zulip/templates/postgresql/9.3/postgresql.conf.template.erb @@ -40,9 +40,9 @@ data_directory = '/var/lib/postgresql/<%= scope["zulip::base::postgres_version"] %>/main' # use data in another directory # (change requires restart) -hba_file = '/etc/postgresql/<%= scope["zulip::base::postgres_version"] %>/main/pg_hba.conf' # host-based authentication file +hba_file = '<%= scope["zulip::postgres_appdb_base::postgres_confdir"] %>/pg_hba.conf' # host-based authentication file # (change requires restart) -ident_file = '/etc/postgresql/<%= scope["zulip::base::postgres_version"] %>/main/pg_ident.conf' # ident configuration file +ident_file = '<%= scope["zulip::postgres_appdb_base::postgres_confdir"] %>/pg_ident.conf' # ident configuration file # (change requires restart) # If external_pid_file is not explicitly set, no extra PID file is written. diff --git a/puppet/zulip/templates/postgresql/9.5/postgresql.conf.template.erb b/puppet/zulip/templates/postgresql/9.5/postgresql.conf.template.erb index a89ce9db3d..1765cc2271 100644 --- a/puppet/zulip/templates/postgresql/9.5/postgresql.conf.template.erb +++ b/puppet/zulip/templates/postgresql/9.5/postgresql.conf.template.erb @@ -40,9 +40,9 @@ data_directory = '/var/lib/postgresql/<%= scope["zulip::base::postgres_version"] %>/main' # use data in another directory # (change requires restart) -hba_file = '/etc/postgresql/<%= scope["zulip::base::postgres_version"] %>/main/pg_hba.conf' # host-based authentication file +hba_file = '<%= scope["zulip::postgres_appdb_base::postgres_confdir"] %>/pg_hba.conf' # host-based authentication file # (change requires restart) -ident_file = '/etc/postgresql/<%= scope["zulip::base::postgres_version"] %>/main/pg_ident.conf' # ident configuration file +ident_file = '<%= scope["zulip::postgres_appdb_base::postgres_confdir"] %>/pg_ident.conf' # ident configuration file # (change requires restart) # If external_pid_file is not explicitly set, no extra PID file is written. diff --git a/puppet/zulip/templates/postgresql/9.6/postgresql.conf.template.erb b/puppet/zulip/templates/postgresql/9.6/postgresql.conf.template.erb index 20473051ce..d9be00be43 100644 --- a/puppet/zulip/templates/postgresql/9.6/postgresql.conf.template.erb +++ b/puppet/zulip/templates/postgresql/9.6/postgresql.conf.template.erb @@ -40,9 +40,9 @@ data_directory = '/var/lib/postgresql/<%= scope["zulip::base::postgres_version"] %>/main' # use data in another directory # (change requires restart) -hba_file = '/etc/postgresql/<%= scope["zulip::base::postgres_version"] %>/main/pg_hba.conf' # host-based authentication file +hba_file = '<%= scope["zulip::postgres_appdb_base::postgres_confdir"] %>/pg_hba.conf' # host-based authentication file # (change requires restart) -ident_file = '/etc/postgresql/<%= scope["zulip::base::postgres_version"] %>/main/pg_ident.conf' # ident configuration file +ident_file = '<%= scope["zulip::postgres_appdb_base::postgres_confdir"] %>/pg_ident.conf' # ident configuration file # (change requires restart) # If external_pid_file is not explicitly set, no extra PID file is written. diff --git a/puppet/zulip_ops/manifests/postgres_appdb.pp b/puppet/zulip_ops/manifests/postgres_appdb.pp index b8fa1dfbee..7eb28fc42a 100644 --- a/puppet/zulip_ops/manifests/postgres_appdb.pp +++ b/puppet/zulip_ops/manifests/postgres_appdb.pp @@ -2,7 +2,7 @@ class zulip_ops::postgres_appdb { include zulip_ops::postgres_common include zulip::postgres_appdb_tuned - file { "/etc/postgresql/${zulip::base::postgres_version}/main/pg_hba.conf": + file { "${zulip::postgres_appdb_base::postgres_confdir}/pg_hba.conf": ensure => file, require => Package["postgresql-${zulip::base::postgres_version}"], owner => 'postgres', diff --git a/puppet/zulip_ops/manifests/postgres_slave.pp b/puppet/zulip_ops/manifests/postgres_slave.pp index 4f2dbac0ed..fc76e4f253 100644 --- a/puppet/zulip_ops/manifests/postgres_slave.pp +++ b/puppet/zulip_ops/manifests/postgres_slave.pp @@ -2,7 +2,7 @@ class zulip_ops::postgres_slave { include zulip_ops::base include zulip_ops::postgres_appdb - file { "/var/lib/postgresql/${zulip::base::postgres_version}/main/recovery.conf": + file { "${zulip::postgres_appdb_base::postgres_confdir}/recovery.conf": ensure => file, require => Package["postgresql-${zulip::base::postgres_version}"], owner => 'postgres',