|
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() |
25 | 25 |
|
26 | 26 | if ($database_schema_path == false) or ($database_schema_path == '') { |
27 | 27 | if member(['CentOS', 'RedHat', 'OracleLinux', 'VirtuozzoLinux'], $facts['os']['name']) { |
28 | | - if versioncmp($zabbix_version, '5.4') >= 0 { |
| 28 | + if versioncmp($zabbix_version, '6.0') >= 0 { |
| 29 | + $schema_path = '/usr/share/zabbix-sql-scripts/postgresql/' |
| 30 | + } elsif versioncmp($zabbix_version, '5.4') >= 0 { |
29 | 31 | $schema_path = '/usr/share/doc/zabbix-sql-scripts/postgresql/' |
30 | 32 | } else { |
31 | 33 | $schema_path = "/usr/share/doc/zabbix-*-pgsql-${zabbix_version}*/" |
32 | 34 | } |
33 | 35 | } else { |
34 | | - if versioncmp($zabbix_version, '5.4') >= 0 { |
| 36 | + if versioncmp($zabbix_version, '6.0') >= 0 { |
| 37 | + $schema_path = '/usr/share/zabbix-sql-scripts/postgresql/' |
| 38 | + } elsif versioncmp($zabbix_version, '5.4') >= 0 { |
35 | 39 | $schema_path = '/usr/share/doc/zabbix-sql-scripts/postgresql/' |
36 | 40 | } else { |
37 | 41 | $schema_path = '/usr/share/doc/zabbix-*-pgsql' |
|
41 | 45 | $schema_path = $database_schema_path |
42 | 46 | } |
43 | 47 |
|
44 | | - if $database_port != undef { |
45 | | - $port = "-p ${database_port} " |
46 | | - } else { |
47 | | - $port = '' |
48 | | - } |
49 | | - |
50 | 48 | case $zabbix_type { |
51 | 49 | 'proxy': { |
52 | 50 | $zabbix_proxy_create_sql = versioncmp($zabbix_version, '6.0') >= 0 ? { |
53 | | - true => "cd ${schema_path} && psql -h '${database_host}' -U '${database_user}' ${port}-d '${database_name}' -f proxy.sql && touch /etc/zabbix/.schema.done", |
54 | | - 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" |
55 | 53 | } |
56 | 54 | } |
57 | 55 | default: { |
58 | 56 | $zabbix_server_create_sql = versioncmp($zabbix_version, '6.0') >= 0 ? { |
59 | | - 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", |
60 | | - 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" |
61 | 59 | } |
62 | 60 | $zabbix_server_images_sql = 'touch /etc/zabbix/.images.done' |
63 | 61 | $zabbix_server_data_sql = 'touch /etc/zabbix/.data.done' |
64 | 62 | } |
65 | 63 | } |
66 | 64 |
|
67 | 65 | exec { 'update_pgpass': |
68 | | - 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", |
69 | 67 | path => "/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:${database_path}", |
70 | | - 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", |
71 | 69 | require => File['/root/.pgpass'], |
72 | 70 | } |
73 | 71 |
|
|
0 commit comments