13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'manifests/database/postgresql.pp', line 13
class zabbix::database::postgresql (
$zabbix_type = '',
$zabbix_version = $zabbix::params::zabbix_version,
$database_schema_path = '',
$database_name = '',
$database_user = '',
$database_password = '',
$database_host = '',
Stdlib::Port::Unprivileged $database_port = 5432,
$database_path = $zabbix::params::database_path,
) inherits zabbix::params {
assert_private()
if $database_schema_path != false and $database_schema_path != '' {
$schema_path = $database_schema_path
} elsif versioncmp($zabbix_version, '6.0') >= 0 {
$schema_path = '/usr/share/zabbix-sql-scripts/postgresql/'
} elsif $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '7' {
$schema_path = "/usr/share/doc/zabbix-*-pgsql-${zabbix_version}*/"
} else {
$schema_path = '/usr/share/doc/zabbix-*-pgsql'
}
$done_file = '/etc/zabbix/.schema.done'
$schema_file = case $zabbix_type {
'proxy': {
if versioncmp($zabbix_version, '6.0') >= 0 {
'proxy.sql'
} else {
'schema.sql'
}
}
default: {
if versioncmp($zabbix_version, '6.0') >= 0 {
'server.sql'
} else {
'create.sql'
}
}
}
$command = "cd ${schema_path} && if [ -f ${schema_file}.gz ]; then zcat ${schema_file}.gz | psql ; else psql -f ${schema_file}; fi && touch ${done_file}"
$exec_env = [
"PGHOST=${database_host}",
"PGPORT=${database_port}",
"PGUSER=${database_user}",
"PGPASSWORD=${database_password}",
"PGDATABASE=${database_name}",
]
exec { 'zabbix_create.sql':
command => $command,
path => "/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:${database_path}",
creates => $done_file,
provider => 'shell',
environment => $exec_env,
}
}
|