From 86cf3be39f8f5c28e10fa7076ce00edde77d7dd1 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Fri, 19 Nov 2021 11:06:59 -0800 Subject: [PATCH] puppet: Fix pgroonga init for custom database names and users. --- puppet/zulip/files/postgresql/pgroonga_setup.sql | 2 -- puppet/zulip/manifests/postgresql_base.pp | 6 ++++-- .../templates/postgresql/pgroonga_setup.sql.template.erb | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) delete mode 100644 puppet/zulip/files/postgresql/pgroonga_setup.sql create mode 100644 puppet/zulip/templates/postgresql/pgroonga_setup.sql.template.erb diff --git a/puppet/zulip/files/postgresql/pgroonga_setup.sql b/puppet/zulip/files/postgresql/pgroonga_setup.sql deleted file mode 100644 index 949e7e056b..0000000000 --- a/puppet/zulip/files/postgresql/pgroonga_setup.sql +++ /dev/null @@ -1,2 +0,0 @@ -CREATE EXTENSION PGROONGA; -GRANT USAGE ON SCHEMA pgroonga TO ZULIP; diff --git a/puppet/zulip/manifests/postgresql_base.pp b/puppet/zulip/manifests/postgresql_base.pp index bf24fc2726..25fb8fc446 100644 --- a/puppet/zulip/manifests/postgresql_base.pp +++ b/puppet/zulip/manifests/postgresql_base.pp @@ -88,19 +88,21 @@ class zulip::postgresql_base { Exec[$setup_system_deps]], } + $dbname = zulipconf('postgresql', 'database_name', 'zulip') + $dbuser = zulipconf('postgresql', 'database_user', 'zulip') file { $pgroonga_setup_sql_path: ensure => file, require => Package["${postgresql}-pgdg-pgroonga"], owner => 'postgres', group => 'postgres', mode => '0640', - source => 'puppet:///modules/zulip/postgresql/pgroonga_setup.sql', + content => template('zulip/postgresql/pgroonga_setup.sql.template.erb'), } exec{'create_pgroonga_extension': require => File[$pgroonga_setup_sql_path], # lint:ignore:140chars - command => "bash -c 'cat ${pgroonga_setup_sql_path} | su postgres -c \"psql -v ON_ERROR_STOP=1 zulip\" && touch ${pgroonga_setup_sql_path}.applied'", + command => "bash -c 'cat ${pgroonga_setup_sql_path} | su postgres -c \"psql -v ON_ERROR_STOP=1 ${dbname}\" && touch ${pgroonga_setup_sql_path}.applied'", # lint:endignore creates => "${pgroonga_setup_sql_path}.applied", } diff --git a/puppet/zulip/templates/postgresql/pgroonga_setup.sql.template.erb b/puppet/zulip/templates/postgresql/pgroonga_setup.sql.template.erb new file mode 100644 index 0000000000..30308caa5a --- /dev/null +++ b/puppet/zulip/templates/postgresql/pgroonga_setup.sql.template.erb @@ -0,0 +1,2 @@ +CREATE EXTENSION PGROONGA; +GRANT USAGE ON SCHEMA pgroonga TO <%= @dbuser %>;