mirror of https://github.com/zulip/zulip.git
puppet: Add postgresql-client depenencies to monitoring.
The `unless` step errors out if /usr/bin/psql does not exist at first evaluation time -- protect that with a `test -f` check, and protect the actual `createuser` with a dependency on `postgresql-client`. To work around `Zulip::Safepackage` not actually being safe to instantiate more than once, we move the instantiation of `Package[postgresql-client]` into a class which can be safely included one or more times.
This commit is contained in:
parent
30c6b26f3b
commit
5308fbdeac
|
@ -10,10 +10,8 @@ class zulip::app_frontend_base {
|
||||||
if $::os['family'] == 'Debian' {
|
if $::os['family'] == 'Debian' {
|
||||||
# Upgrade and other tooling wants to be able to get a database
|
# Upgrade and other tooling wants to be able to get a database
|
||||||
# shell. This is not necessary on CentOS because the PostgreSQL
|
# shell. This is not necessary on CentOS because the PostgreSQL
|
||||||
# package already includes the client. This may get us a more
|
# package already includes the client.
|
||||||
# recent client than the database server is configured to be,
|
include zulip::postgresql_client
|
||||||
# ($zulip::postgresql_common::version), but they're compatible.
|
|
||||||
zulip::safepackage { 'postgresql-client': ensure => installed }
|
|
||||||
}
|
}
|
||||||
# For Slack import
|
# For Slack import
|
||||||
zulip::safepackage { 'unzip': ensure => installed }
|
zulip::safepackage { 'unzip': ensure => installed }
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
class zulip::postgresql_client {
|
||||||
|
# This may get us a more recent client than the database server is
|
||||||
|
# configured to be, ($zulip::postgresql_common::version), but
|
||||||
|
# they're compatible.
|
||||||
|
package { 'postgresql-client':
|
||||||
|
ensure => installed,
|
||||||
|
}
|
||||||
|
}
|
|
@ -47,9 +47,11 @@ class zulip_ops::prometheus::postgresql {
|
||||||
require => Exec['compile postgres_exporter'],
|
require => Exec['compile postgres_exporter'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
include zulip::postgresql_client
|
||||||
exec { 'create prometheus postgres user':
|
exec { 'create prometheus postgres user':
|
||||||
|
require => Package['postgresql-client'],
|
||||||
command => '/usr/bin/createuser -g pg_monitor prometheus',
|
command => '/usr/bin/createuser -g pg_monitor prometheus',
|
||||||
unless => '/usr/bin/psql -tAc "select usename from pg_user" | /bin/grep -xq prometheus',
|
unless => 'test -f /usr/bin/psql && /usr/bin/psql -tAc "select usename from pg_user" | /bin/grep -xq prometheus',
|
||||||
user => 'postgres',
|
user => 'postgres',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue