Skip to content

Commit d55d210

Browse files
refactor: set default database port to 5432
fix: linter
1 parent 2686e33 commit d55d210

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

manifests/database/postgresql.pp

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
$database_user = '',
1919
$database_password = '',
2020
$database_host = '',
21-
Optional[Stdlib::Port::Unprivileged] $database_port = undef,
21+
Stdlib::Port::Unprivileged $database_port = 5432,
2222
$database_path = $zabbix::params::database_path,
2323
) inherits zabbix::params {
2424
assert_private()
@@ -45,35 +45,27 @@
4545
$schema_path = $database_schema_path
4646
}
4747

48-
if $database_port != undef {
49-
$port = "-p ${database_port} "
50-
} else {
51-
$port = ''
52-
}
53-
5448
case $zabbix_type {
5549
'proxy': {
5650
$zabbix_proxy_create_sql = versioncmp($zabbix_version, '6.0') >= 0 ? {
57-
true => "cd ${schema_path} && psql -h '${database_host}' -U '${database_user}' ${port}-d '${database_name}' -f proxy.sql && touch /etc/zabbix/.schema.done",
58-
false => "cd ${schema_path} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && psql -h '${database_host}' -U '${database_user}' ${port}-d '${database_name}' -f schema.sql && touch /etc/zabbix/.schema.done"
51+
true => "cd ${schema_path} && psql -h '${database_host}' -U '${database_user}' -p ${database_port} -d '${database_name}' -f proxy.sql && touch /etc/zabbix/.schema.done",
52+
false => "cd ${schema_path} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && psql -h '${database_host}' -U '${database_user}' -p ${database_port} -d '${database_name}' -f schema.sql && touch /etc/zabbix/.schema.done"
5953
}
6054
}
6155
default: {
6256
$zabbix_server_create_sql = versioncmp($zabbix_version, '6.0') >= 0 ? {
63-
true => "cd ${schema_path} && if [ -f server.sql.gz ]; then gunzip -f server.sql.gz ; fi && psql -h '${database_host}' -U '${database_user}' ${port}-d '${database_name}' -f server.sql && touch /etc/zabbix/.schema.done",
64-
false => "cd ${schema_path} && if [ -f create.sql.gz ]; then gunzip -f create.sql.gz ; fi && psql -h '${database_host}' -U '${database_user}' ${port}-d '${database_name}' -f create.sql && touch /etc/zabbix/.schema.done"
57+
true => "cd ${schema_path} && if [ -f server.sql.gz ]; then gunzip -f server.sql.gz ; fi && psql -h '${database_host}' -U '${database_user}' -p ${database_port} -d '${database_name}' -f server.sql && touch /etc/zabbix/.schema.done",
58+
false => "cd ${schema_path} && if [ -f create.sql.gz ]; then gunzip -f create.sql.gz ; fi && psql -h '${database_host}' -U '${database_user}' -p ${database_port} -d '${database_name}' -f create.sql && touch /etc/zabbix/.schema.done"
6559
}
6660
$zabbix_server_images_sql = 'touch /etc/zabbix/.images.done'
6761
$zabbix_server_data_sql = 'touch /etc/zabbix/.data.done'
6862
}
6963
}
7064

71-
$db_port = pick($database_port, '5432')
72-
7365
exec { 'update_pgpass':
74-
command => "echo ${database_host}:${db_port}:${database_name}:${database_user}:${database_password} >> /root/.pgpass",
66+
command => "echo ${database_host}:${database_port}:${database_name}:${database_user}:${database_password} >> /root/.pgpass",
7567
path => "/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:${database_path}",
76-
unless => "grep \"${database_host}:${db_port}:${database_name}:${database_user}:${database_password}\" /root/.pgpass",
68+
unless => "grep \"${database_host}:${database_port}:${database_name}:${database_user}:${database_password}\" /root/.pgpass",
7769
require => File['/root/.pgpass'],
7870
}
7971

0 commit comments

Comments
 (0)