kandra: Skip prometheus database user creation.

This commit is contained in:
Alex Vandiver 2024-03-29 04:19:18 +00:00 committed by Tim Abbott
parent da243e9fb7
commit 3c2efd236c
1 changed files with 16 additions and 7 deletions

View File

@ -47,19 +47,28 @@ class kandra::prometheus::postgresql {
require => Exec['compile postgres_exporter'], require => Exec['compile postgres_exporter'],
} }
include zulip::postgresql_client if false {
exec { 'create prometheus postgres user': # This is left commented out, since it only makes sense to run
require => Class['zulip::postgresql_client'], # against a server where the database exists and is writable --
command => '/usr/bin/createuser -g pg_monitor prometheus', # the former of which happens outside th scope of puppet right
unless => 'test -f /usr/bin/psql && /usr/bin/psql -tAc "select usename from pg_user" | /bin/grep -xq prometheus', # now, and the latter of which can only be determined after the
user => 'postgres', # database is in place. Given that it has been run once, we do
# not expect to ever need it to run again; it is left here for
# completeness.
include zulip::postgresql_client
exec { 'create prometheus postgres user':
require => Class['zulip::postgresql_client'],
command => '/usr/bin/createuser -g pg_monitor prometheus',
unless => 'test -f /usr/bin/psql && /usr/bin/psql -tAc "select usename from pg_user" | /bin/grep -xq prometheus)',
user => 'postgres',
before => File["${zulip::common::supervisor_conf_dir}/prometheus_postgres_exporter.conf"],
}
} }
kandra::firewall_allow { 'postgres_exporter': port => '9187' } kandra::firewall_allow { 'postgres_exporter': port => '9187' }
file { "${zulip::common::supervisor_conf_dir}/prometheus_postgres_exporter.conf": file { "${zulip::common::supervisor_conf_dir}/prometheus_postgres_exporter.conf":
ensure => file, ensure => file,
require => [ require => [
Exec['create prometheus postgres user'],
User[prometheus], User[prometheus],
Package[supervisor], Package[supervisor],
File[$bin], File[$bin],