Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Zabbix 5.x #743

Merged
merged 10 commits into from
Mar 14, 2021
4 changes: 2 additions & 2 deletions manifests/database/mysql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
assert_private()

#
# Adjustments for version 3.0/4.0 - structure of package with sqls differs from previous versions
# Adjustments for version 3.x/4.x/5.x - structure of package with sqls differs from previous versions
case $zabbix_version {
/^(3|4).\d+$/: {
/^[345].\d+$/: {
root-expert marked this conversation as resolved.
Show resolved Hide resolved
if ($database_schema_path == false) or ($database_schema_path == '') {
$schema_path = '/usr/share/doc/zabbix-*-mysql*'
}
Expand Down
4 changes: 2 additions & 2 deletions manifests/database/postgresql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
assert_private()

#
# Adjustments for version 3.0/4.0 - structure of package with sqls differs from previous versions
# Adjustments for version 3.x/4.x/5.x - structure of package with sqls differs from previous versions
case $zabbix_version {
/^(3|4).\d+$/: {
/^[345].\d+$/: {
if ($database_schema_path == false) or ($database_schema_path == '') {
case $facts['os']['name'] {
'CentOS', 'RedHat', 'OracleLinux', 'VirtuozzoLinux': {
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
$manage_apt = true
$repo_location = undef
$unsupported_repo_location = undef
$frontend_repo_location = undef
$manage_resources = false
$manage_vhost = true
$database_path = '/usr/sbin'
Expand Down
38 changes: 28 additions & 10 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,27 @@
Boolean $manage_repo = $zabbix::params::manage_repo,
Boolean $manage_apt = $zabbix::params::manage_apt,
Optional[Stdlib::HTTPUrl] $repo_location = $zabbix::params::repo_location,
Optional[Stdlib::HTTPUrl] $frontend_repo_location = $zabbix::params::frontend_repo_location,
Optional[Stdlib::HTTPUrl] $unsupported_repo_location = $zabbix::params::unsupported_repo_location,
String[1] $zabbix_version = $zabbix::params::zabbix_version,
) inherits zabbix::params {
if ($manage_repo) {
case $facts['os']['name'] {
'PSBM' : {
'PSBM': {
$majorrelease = '6'
}
'Amazon' : {
'Amazon': {
$majorrelease = '6'
}
'oraclelinux' : {
'oraclelinux': {
$majorrelease = $facts['os']['release']['major']
}
default : {
default: {
$majorrelease = $facts['os']['release']['major']
}
}
case $facts['os']['family'] {
'RedHat' : {
'RedHat': {
# Zabbix-3.2 and newer RPMs are signed with the GPG key
if versioncmp($zabbix_version, '3.2') < 0 {
$gpgkey_zabbix = 'https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX'
Expand Down Expand Up @@ -92,8 +93,25 @@
gpgkey => $gpgkey_nonsupported,
priority => '1',
}

# Zabbix 5.0 frontend on CentOS 7 has different location.
if ($facts['os']['name'] == 'CentOS' and $majorrelease == '7' and $zabbix_version == '5.0') {
$_frontend_repo_location = $frontend_repo_location ? {
undef => "https://repo.zabbix.com/zabbix/${zabbix_version}/rhel/${majorrelease}/\$basearch/frontend",
default => $frontend_repo_location,
}

yumrepo { 'zabbix-frontend':
name => "Zabbix_frontend_${majorrelease}_${facts['os']['architecture']}",
descr => "Zabbix_frontend_${majorrelease}_${facts['os']['architecture']}",
baseurl => $_frontend_repo_location,
gpgcheck => '1',
gpgkey => $gpgkey_zabbix,
priority => '1',
}
}
}
'Debian' : {
'Debian': {
if ($manage_apt) {
# We would like to provide the repos with https urls instead of http
# this requires the apt-transport-https package, but we don't want to manage
Expand Down Expand Up @@ -128,8 +146,8 @@
$operatingsystem = downcase($facts['os']['name'])
}
case $facts['os']['release']['full'] {
/\/sid$/ : { $releasename = regsubst($facts['os']['release']['full'], '/sid$', '') }
default : { $releasename = $facts['os']['distro']['codename'] }
/\/sid$/: { $releasename = regsubst($facts['os']['release']['full'], '/sid$', '') }
default: { $releasename = $facts['os']['distro']['codename'] }
}

$_repo_location = $repo_location ? {
Expand All @@ -156,9 +174,9 @@
}
}
Apt::Source['zabbix'] -> Package<|tag == 'zabbix'|>
Class['Apt::Update'] -> Package<|tag == 'zabbix'|>
Class['Apt::Update'] -> Package<|tag == 'zabbix'|>
}
default : {
default: {
fail("Managing a repo on ${facts['os']['family']} is currently not implemented")
}
}
Expand Down
8 changes: 8 additions & 0 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,14 @@
Boolean $manage_startup_script = $zabbix::params::manage_startup_script,
Optional[Stdlib::Absolutepath] $socketdir = $zabbix::params::server_socketdir,
) inherits zabbix::params {
# zabbix server 5.2 is not supported on RHEL 7.
# https://www.zabbix.com/documentation/current/manual/installation/install_from_packages/rhel_centos
if $facts['os']['family'] == 'RedHat' and versioncmp($zabbix_version, '5.2') == 0 {
if versioncmp($facts['os']['release']['major'], '7') == 0 {
fail("${facts['os']['family']} ${$facts['os']['release']['major']} is not supported for zabbix::server (yet)")
}
}

# the following codeblock is a bit blargh. The correct default value for
# $real_additional_service_params changes based on the value of $zabbix_version
# We handle this in the params.pp, but that doesn't work if somebody provides a specific
Expand Down
124 changes: 109 additions & 15 deletions manifests/web.pp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@
fail("${facts['os']['family']} is currently not supported for zabbix::web")
}

# zabbix frontend 5.x is not supported, among others, on stretch and xenial.
# https://www.zabbix.com/documentation/current/manual/installation/frontend/frontend_on_debian
if $facts['os']['name'] in ['ubuntu', 'debian'] and versioncmp($zabbix_version, '5') >= 0 {
if versioncmp($facts['os']['release']['major'], '16.04') == 0 or versioncmp($facts['os']['release']['major'], '9') == 0 {
fail("${facts['os']['family']} ${$facts['os']['release']['major']} is not supported for zabbix::web")
}
}

# Only include the repo class if it has not yet been included
unless defined(Class['Zabbix::Repo']) {
class { 'zabbix::repo':
Expand Down Expand Up @@ -279,9 +287,18 @@
'3.4' : {
$zabbixapi_version = '4.0.0'
}
default : {
'4.0': {
$zabbixapi_version = '4.2.0'
}
'4.4': {
$zabbixapi_version = '4.2.0'
}
/^5\.[02]/: {
$zabbixapi_version = '5.0.0-alpha1'
}
default: {
fail("Zabbix ${zabbix_version} is not supported!")
}
}

# Installing the zabbixapi gem package. We need this gem for
Expand Down Expand Up @@ -340,6 +357,29 @@
],
}
}
'CentOS', 'RedHat': {
$zabbix_web_package = 'zabbix-web'
if ($facts['os']['release']['major'] == '7' and versioncmp($zabbix_version, '5') >= 0) {
package { 'zabbix-required-scl-repo':
ensure => 'latest',
name => 'centos-release-scl',
}

package { "zabbix-web-${db}-scl":
ensure => $zabbix_package_state,
before => Package[$zabbix_web_package],
require => Class['zabbix::repo'],
tag => 'zabbix',
}
} else {
package { "zabbix-web-${db}":
ensure => $zabbix_package_state,
before => Package[$zabbix_web_package],
require => Class['zabbix::repo'],
tag => 'zabbix',
}
}
}
default: {
$zabbix_web_package = 'zabbix-web'

Expand Down Expand Up @@ -377,9 +417,69 @@
content => template('zabbix/web/zabbix.conf.php.erb'),
}

# For API to work on Zabbix 5.x zabbix.conf.php needs to be in the root folder.
if versioncmp($zabbix_version, '5') >= 0 {
file { '/etc/zabbix/zabbix.conf.php':
ensure => link,
target => '/etc/zabbix/web/zabbix.conf.php',
owner => $web_config_owner,
group => $web_config_group,
mode => '0640',
}
}

# Is set to true, it will create the apache vhost.
if $manage_vhost {
include apache
if $facts['os']['family'] == 'RedHat' and versioncmp($facts['os']['release']['major'], '7') == 0 and versioncmp($zabbix_version, '5') >= 0 {
include apache::mod::proxy
include apache::mod::proxy_fcgi
$apache_vhost_custom_fragment = ''

service { 'rh-php72-php-fpm':
ensure => 'running',
enable => true,
}

# PHP parameters are moved to /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf per package zabbix-web-deps-scl
file { '/etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf':
ensure => file,
notify => Service['rh-php72-php-fpm'],
content => epp('zabbix/web/php-fpm.d.zabbix.conf.epp'),
}

$fcgi_filematch = {
path => '/usr/share/zabbix',
provider => 'directory',
addhandlers => [
{
extensions => [
'php',
'phar',
],
handler => 'proxy:unix:/var/opt/rh/rh-php72/run/php-fpm/zabbix.sock|fcgi://localhost',
},
],
}
$proxy_directory = {
path => 'fcgi://localhost:9000',
provider => 'proxy',
}
}
else {
$apache_vhost_custom_fragment = "
php_value max_execution_time ${apache_php_max_execution_time}
php_value memory_limit ${apache_php_memory_limit}
php_value post_max_size ${apache_php_post_max_size}
php_value upload_max_filesize ${apache_php_upload_max_filesize}
php_value max_input_time ${apache_php_max_input_time}
php_value always_populate_raw_post_data ${apache_php_always_populate_raw_post_data}
php_value max_input_vars ${apache_php_max_input_vars}
# Set correct timezone
php_value date.timezone ${zabbix_timezone}"
$fcgi_filematch = {}
$proxy_directory = {}
}
# Check if we use ssl. If so, we also create an non ssl
# vhost for redirect traffic from non ssl to ssl site.
if $apache_use_ssl {
Expand Down Expand Up @@ -424,10 +524,13 @@
default_vhost => $default_vhost,
add_listen => true,
directories => [
merge( {
path => '/usr/share/zabbix',
provider => 'directory',
}, $directory_allow),
merge(
merge( {
path => '/usr/share/zabbix',
provider => 'directory',
}, $directory_allow),
$fcgi_filematch
),
merge( {
path => '/usr/share/zabbix/conf',
provider => 'directory',
Expand All @@ -445,16 +548,7 @@
provider => 'directory',
}, $directory_deny),
],
custom_fragment => "
php_value max_execution_time ${apache_php_max_execution_time}
php_value memory_limit ${apache_php_memory_limit}
php_value post_max_size ${apache_php_post_max_size}
php_value upload_max_filesize ${apache_php_upload_max_filesize}
php_value max_input_time ${apache_php_max_input_time}
php_value always_populate_raw_post_data ${apache_php_always_populate_raw_post_data}
php_value max_input_vars ${apache_php_max_input_vars}
# Set correct timezone
php_value date.timezone ${zabbix_timezone}",
custom_fragment => $apache_vhost_custom_fragment,
rewrites => [
{
rewrite_rule => ['^$ /index.php [L]'] }
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def agent_supported(version)
true
end

['2.4', '3.2', '3.4', '4.0', '4.2', '4.4'].each do |version|
['2.4', '3.2', '3.4', '4.0', '4.2', '4.4', '5.0', '5.2'].each do |version|
describe "zabbix::agent class with zabbix_version #{version}", if: agent_supported(version) do
it 'works idempotently with no errors' do
pp = <<-EOS
Expand Down
Loading