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
71
72
73
74
75
76
77
78
79
80
|
# File 'manifests/javagateway.pp', line 16
class zabbix::javagateway (
$zabbix_version = $zabbix::params::zabbix_version,
$zabbix_package_state = $zabbix::params::zabbix_package_state,
Boolean $manage_firewall = $zabbix::params::manage_firewall,
Boolean $manage_repo = $zabbix::params::manage_repo,
$pidfile = $zabbix::params::javagateway_pidfile,
$listenip = $zabbix::params::javagateway_listenip,
$listenport = $zabbix::params::javagateway_listenport,
$startpollers = $zabbix::params::javagateway_startpollers,
$timeout = $zabbix::params::javagateway_timeout,
) inherits zabbix::params {
# Fix for pid file. Is different in Zabbix (4, 5) and 6
$real_pidfile = $zabbix_version ? {
/^[45]\.[024]/ => pick($pidfile, '/var/run/zabbix/zabbix_java.pid'),
/^[6]\.[024]/ => pick($pidfile, '/var/run/zabbix/zabbix_java_gateway.pid'),
}
# Only include the repo class if it has not yet been included
unless defined(Class['Zabbix::Repo']) {
class { 'zabbix::repo':
manage_repo => $manage_repo,
zabbix_version => $zabbix_version,
}
}
# Installing the package
package { 'zabbix-java-gateway':
ensure => $zabbix_package_state,
require => Class['zabbix::repo'],
tag => 'zabbix',
}
# Configuring the zabbix-javagateway configuration file
file { '/etc/zabbix/zabbix_java_gateway.conf':
ensure => file,
owner => 'zabbix',
group => 'zabbix',
mode => '0640',
notify => Service['zabbix-java-gateway'],
require => Package['zabbix-java-gateway'],
replace => true,
content => template('zabbix/zabbix_java_gateway.conf.erb'),
}
# Controlling the 'zabbix-java-gateway' service
service { 'zabbix-java-gateway':
ensure => running,
enable => true,
hasstatus => true,
hasrestart => true,
require => [
Package['zabbix-java-gateway'],
File['/etc/zabbix/zabbix_java_gateway.conf']
],
}
# Manage firewall
if $manage_firewall {
firewall { '152 zabbix-javagateway':
dport => $listenport,
proto => 'tcp',
jump => 'accept',
state => ['NEW','RELATED', 'ESTABLISHED'],
}
}
}
|