Skip to content

Commit 4e069f9

Browse files
authored
Merge pull request #1 from voxpupuli/master
rebase on current master
2 parents e6b031f + 5c624b8 commit 4e069f9

File tree

7 files changed

+60
-29
lines changed

7 files changed

+60
-29
lines changed

manifests/database/mysql.pp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
assert_private()
2525

2626
if ($database_schema_path == false) or ($database_schema_path == '') {
27-
if versioncmp($zabbix_version, '5.4') >= 0 {
27+
if versioncmp($zabbix_version, '6.0') >= 0 {
28+
$schema_path = '/usr/share/zabbix-sql-scripts/mysql/'
29+
} elsif versioncmp($zabbix_version, '5.4') >= 0 {
2830
$schema_path = '/usr/share/doc/zabbix-sql-scripts/mysql/'
2931
} else {
3032
$schema_path = '/usr/share/doc/zabbix-*-mysql*'

manifests/database/postgresql.pp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,24 @@
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()
2525

2626
if ($database_schema_path == false) or ($database_schema_path == '') {
2727
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 {
2931
$schema_path = '/usr/share/doc/zabbix-sql-scripts/postgresql/'
3032
} else {
3133
$schema_path = "/usr/share/doc/zabbix-*-pgsql-${zabbix_version}*/"
3234
}
3335
} 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 {
3539
$schema_path = '/usr/share/doc/zabbix-sql-scripts/postgresql/'
3640
} else {
3741
$schema_path = '/usr/share/doc/zabbix-*-pgsql'
@@ -41,33 +45,27 @@
4145
$schema_path = $database_schema_path
4246
}
4347

44-
if $database_port != undef {
45-
$port = "-p ${database_port} "
46-
} else {
47-
$port = ''
48-
}
49-
5048
case $zabbix_type {
5149
'proxy': {
5250
$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"
5553
}
5654
}
5755
default: {
5856
$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"
6159
}
6260
$zabbix_server_images_sql = 'touch /etc/zabbix/.images.done'
6361
$zabbix_server_data_sql = 'touch /etc/zabbix/.data.done'
6462
}
6563
}
6664

6765
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",
6967
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",
7169
require => File['/root/.pgpass'],
7270
}
7371

manifests/web.pp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@
306306
# Is set to true, it will create the apache vhost.
307307
if $manage_vhost {
308308
include apache
309+
include apache::mod::dir
309310
if $facts['os']['family'] == 'RedHat' and versioncmp($facts['os']['release']['major'], '7') >= 0 and versioncmp($zabbix_version, '5') >= 0 {
310311
if versioncmp($facts['os']['release']['major'], '7') == 0 {
311312
$fpm_service = 'rh-php72-php-fpm'
@@ -407,25 +408,25 @@
407408
add_listen => true,
408409
directories => [
409410
merge(
410-
merge( {
411+
merge({
411412
path => '/usr/share/zabbix',
412413
provider => 'directory',
413414
}, $directory_allow),
414415
$fcgi_filematch
415416
),
416-
merge( {
417+
merge({
417418
path => '/usr/share/zabbix/conf',
418419
provider => 'directory',
419420
}, $directory_deny),
420-
merge( {
421+
merge({
421422
path => '/usr/share/zabbix/api',
422423
provider => 'directory',
423424
}, $directory_deny),
424-
merge( {
425+
merge({
425426
path => '/usr/share/zabbix/include',
426427
provider => 'directory',
427428
}, $directory_deny),
428-
merge( {
429+
merge({
429430
path => '/usr/share/zabbix/include/classes',
430431
provider => 'directory',
431432
}, $directory_deny),

metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"dependencies": [
77
{
88
"name": "puppetlabs/postgresql",
9-
"version_requirement": ">= 6.4.0 < 8.0.0"
9+
"version_requirement": ">= 6.4.0 < 9.0.0"
1010
},
1111
{
1212
"name": "puppetlabs/stdlib",

spec/acceptance/zabbix_host_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@
2929
['Template OS Linux SNMPv2']
3030
when '5.0'
3131
['Template OS Linux SNMP']
32-
else
32+
when '5.2', '5.4'
3333
['Linux SNMP']
34+
else
35+
['Linux by SNMP']
3436
end
3537

3638
pp1 = <<-EOS

spec/classes/database_mysql_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727

2828
supported_versions.each do |zabbix_version|
2929
# path to sql files on Debian and RedHat
30-
path = if Puppet::Util::Package.versioncmp(zabbix_version, '5.4') >= 0
30+
path = if Puppet::Util::Package.versioncmp(zabbix_version, '6.0') >= 0
31+
'/usr/share/zabbix-sql-scripts/mysql/'
32+
elsif Puppet::Util::Package.versioncmp(zabbix_version, '5.4') >= 0
3133
'/usr/share/doc/zabbix-sql-scripts/mysql/'
3234
else
3335
'/usr/share/doc/zabbix-*-mysql*'

spec/classes/database_postgresql_spec.rb

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,18 @@
2323
path = case facts[:os]['name']
2424
when 'CentOS', 'RedHat', 'OracleLinux', 'VirtuozzoLinux'
2525
# Path on RedHat
26-
if Puppet::Util::Package.versioncmp(zabbix_version, '5.4') >= 0
26+
if Puppet::Util::Package.versioncmp(zabbix_version, '6.0') >= 0
27+
'/usr/share/zabbix-sql-scripts/postgresql/'
28+
elsif Puppet::Util::Package.versioncmp(zabbix_version, '5.4') >= 0
2729
'/usr/share/doc/zabbix-sql-scripts/postgresql/'
2830
else
2931
"/usr/share/doc/zabbix-*-pgsql-#{zabbix_version}*/"
3032
end
3133
else
3234
# Path on Debian
33-
if Puppet::Util::Package.versioncmp(zabbix_version, '5.4') >= 0
35+
if Puppet::Util::Package.versioncmp(zabbix_version, '6.0') >= 0
36+
'/usr/share/zabbix-sql-scripts/postgresql/'
37+
elsif Puppet::Util::Package.versioncmp(zabbix_version, '5.4') >= 0
3438
'/usr/share/doc/zabbix-sql-scripts/postgresql/'
3539
else
3640
'/usr/share/doc/zabbix-*-pgsql'
@@ -80,7 +84,29 @@
8084

8185
it { is_expected.to compile.with_all_deps }
8286
it { is_expected.to contain_exec('update_pgpass').with_command('echo node01.example.com:5432:zabbix-server:zabbix-server:zabbix-server >> /root/.pgpass') }
83-
it { is_expected.to contain_exec('zabbix_server_create.sql').with_command("cd #{path} && if [ -f #{sql_server}.gz ]; then gunzip -f #{sql_server}.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-server' -d 'zabbix-server' -f #{sql_server} && touch /etc/zabbix/.schema.done") }
87+
it { is_expected.to contain_exec('zabbix_server_create.sql').with_command("cd #{path} && if [ -f #{sql_server}.gz ]; then gunzip -f #{sql_server}.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-server' -p 5432 -d 'zabbix-server' -f #{sql_server} && touch /etc/zabbix/.schema.done") }
88+
it { is_expected.to contain_exec('zabbix_server_images.sql').with_command('touch /etc/zabbix/.images.done') }
89+
it { is_expected.to contain_exec('zabbix_server_data.sql').with_command('touch /etc/zabbix/.data.done') }
90+
it { is_expected.to contain_file('/root/.pgpass') }
91+
it { is_expected.to contain_class('zabbix::params') }
92+
end
93+
94+
describe "when zabbix_type is server and version is #{zabbix_version} and custom port is defined" do
95+
let :params do
96+
{
97+
database_name: 'zabbix-server',
98+
database_user: 'zabbix-server',
99+
database_password: 'zabbix-server',
100+
database_host: 'node01.example.com',
101+
database_port: 6432,
102+
zabbix_type: 'server',
103+
zabbix_version: zabbix_version
104+
}
105+
end
106+
107+
it { is_expected.to compile.with_all_deps }
108+
it { is_expected.to contain_exec('update_pgpass').with_command('echo node01.example.com:6432:zabbix-server:zabbix-server:zabbix-server >> /root/.pgpass') }
109+
it { is_expected.to contain_exec('zabbix_server_create.sql').with_command("cd #{path} && if [ -f #{sql_server}.gz ]; then gunzip -f #{sql_server}.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-server' -p 6432 -d 'zabbix-server' -f #{sql_server} && touch /etc/zabbix/.schema.done") }
84110
it { is_expected.to contain_exec('zabbix_server_images.sql').with_command('touch /etc/zabbix/.images.done') }
85111
it { is_expected.to contain_exec('zabbix_server_data.sql').with_command('touch /etc/zabbix/.data.done') }
86112
it { is_expected.to contain_file('/root/.pgpass') }
@@ -127,9 +153,9 @@
127153
it { is_expected.to contain_exec('update_pgpass').with_command('echo node01.example.com:5432:zabbix-proxy:zabbix-proxy:zabbix-proxy >> /root/.pgpass') }
128154

129155
if Puppet::Util::Package.versioncmp(zabbix_version, '6.0') < 0
130-
it { is_expected.to contain_exec('zabbix_proxy_create.sql').with_command("cd #{path} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-proxy' -d 'zabbix-proxy' -f schema.sql && touch /etc/zabbix/.schema.done") }
156+
it { is_expected.to contain_exec('zabbix_proxy_create.sql').with_command("cd #{path} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-proxy' -p 5432 -d 'zabbix-proxy' -f schema.sql && touch /etc/zabbix/.schema.done") }
131157
else
132-
it { is_expected.to contain_exec('zabbix_proxy_create.sql').with_command("cd #{path} && psql -h 'node01.example.com' -U 'zabbix-proxy' -d 'zabbix-proxy' -f proxy.sql && touch /etc/zabbix/.schema.done") }
158+
it { is_expected.to contain_exec('zabbix_proxy_create.sql').with_command("cd #{path} && psql -h 'node01.example.com' -U 'zabbix-proxy' -p 5432 -d 'zabbix-proxy' -f proxy.sql && touch /etc/zabbix/.schema.done") }
133159
end
134160

135161
it { is_expected.to contain_class('zabbix::params') }

0 commit comments

Comments
 (0)