Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

puppet: Fix pgroonga init for custom database names and users.

Alex Vandiver86cf3be39f8f
diff --git a/puppet/zulip/files/postgresql/pgroonga_setup.sql b/puppet/zulip/files/postgresql/pgroonga_setup.sql
deleted file mode 100644
index 949e7e056b5..00000000000
--- 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 bf24fc27260..25fb8fc4460 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 00000000000..30308caa5a5
--- /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 %>;