|
18 | 18 | $database_user = '', |
19 | 19 | $database_password = '', |
20 | 20 | $database_host = '', |
21 | | - Optional[Stdlib::Port::Unprivileged] $database_port = undef, |
| 21 | + Stdlib::Port::Unprivileged $database_port = 5432, |
22 | 22 | $database_path = $zabbix::params::database_path, |
23 | 23 | ) inherits zabbix::params { |
24 | 24 | assert_private() |
|
45 | 45 | $schema_path = $database_schema_path |
46 | 46 | } |
47 | 47 |
|
48 | | - if $database_port != undef { |
49 | | - $port = "-p ${database_port} " |
50 | | - } else { |
51 | | - $port = '' |
52 | | - } |
53 | | - |
54 | 48 | case $zabbix_type { |
55 | 49 | 'proxy': { |
56 | 50 | $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" |
59 | 53 | } |
60 | 54 | } |
61 | 55 | default: { |
62 | 56 | $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" |
65 | 59 | } |
66 | 60 | $zabbix_server_images_sql = 'touch /etc/zabbix/.images.done' |
67 | 61 | $zabbix_server_data_sql = 'touch /etc/zabbix/.data.done' |
68 | 62 | } |
69 | 63 | } |
70 | 64 |
|
71 | 65 | exec { 'update_pgpass': |
72 | | - command => "echo ${database_host}:5432:${database_name}:${database_user}:${database_password} >> /root/.pgpass", |
| 66 | + command => "echo ${database_host}:${database_port}:${database_name}:${database_user}:${database_password} >> /root/.pgpass", |
73 | 67 | path => "/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:${database_path}", |
74 | | - unless => "grep \"${database_host}:5432:${database_name}:${database_user}:${database_password}\" /root/.pgpass", |
| 68 | + unless => "grep \"${database_host}:${database_port}:${database_name}:${database_user}:${database_password}\" /root/.pgpass", |
75 | 69 | require => File['/root/.pgpass'], |
76 | 70 | } |
77 | 71 |
|
|
0 commit comments