Skip to content

Commit

Permalink
move zabbixapi gem installation into own class
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Nov 6, 2023
1 parent e4894b8 commit 44c3feb
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 28 deletions.
28 changes: 28 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* [`zabbix::server`](#zabbix--server): This will install and configure the zabbix-server deamon
* [`zabbix::userparameter`](#zabbix--userparameter): This class can be used when you use hiera or The Foreman. With this tools you can't use and define. This make use of "create_resources".
* [`zabbix::web`](#zabbix--web): This will install the zabbix-web package and install an virtual host.
* [`zabbix::zabbixapi`](#zabbix--zabbixapi): This will install the zabbixapi gem.
* [`zabbix::zapache`](#zabbix--zapache): This will install and configure the zapache monitoring script Upstream: https://github.com/lorf/zapache

#### Private Classes
Expand Down Expand Up @@ -5427,6 +5428,33 @@ Whether we should manage SELinux rules.

Default value: `$zabbix::params::manage_selinux`

### <a name="zabbix--zabbixapi"></a>`zabbix::zabbixapi`

This will install the zabbixapi gem.

#### Parameters

The following parameters are available in the `zabbix::zabbixapi` class:

* [`zabbix_version`](#-zabbix--zabbixapi--zabbix_version)
* [`puppetgem`](#-zabbix--zabbixapi--puppetgem)

##### <a name="-zabbix--zabbixapi--zabbix_version"></a>`zabbix_version`

Data type: `Any`

This is the zabbix version.

Default value: `$zabbix::params::zabbix_version`

##### <a name="-zabbix--zabbixapi--puppetgem"></a>`puppetgem`

Data type: `Any`

Provider for the zabbixapi gem package.

Default value: `$zabbix::params::puppetgem`

### <a name="zabbix--zapache"></a>`zabbix::zapache`

This will install and configure the zapache monitoring script Upstream: https://github.com/lorf/zapache
Expand Down
19 changes: 3 additions & 16 deletions manifests/web.pp
Original file line number Diff line number Diff line change
Expand Up @@ -186,28 +186,15 @@
# is set to false, you'll get warnings like this:
# "Warning: You cannot collect without storeconfigs being set"
if $manage_resources {
# Determine correct zabbixapi version.
case $zabbix_version {
/^[56]\.[024]/: {
$zabbixapi_version = '5.0.0-alpha1'
}
default: {
fail("Zabbix ${zabbix_version} is not supported!")
}
}

# Installing the zabbixapi gem package. We need this gem for
# communicating with the zabbix-api. This is way better then
# doing it ourself.
file { $zabbix_template_dir:
ensure => directory,
owner => 'zabbix',
group => 'zabbix',
mode => '0755',
}
-> package { 'zabbixapi':
ensure => $zabbixapi_version,
provider => $puppetgem,
-> class { 'zabbix::zabbixapi':
zabbix_version => $zabbix_version,
puppetgem => $puppetgem,
}
-> class { 'zabbix::resources::web':
zabbix_url => $zabbix_url,
Expand Down
34 changes: 34 additions & 0 deletions manifests/zabbixapi.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# @summary This will install the zabbixapi gem.
#
# @param zabbix_version This is the zabbix version.
# @param puppetgem Provider for the zabbixapi gem package.
class zabbix::zabbixapi(

Check failure on line 5 in manifests/zabbixapi.pp

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

there should be a single space between the class or resource name and the next item (check: manifest_whitespace_class_name_single_space_after)
$zabbix_version = $zabbix::params::zabbix_version,
$puppetgem = $zabbix::params::puppetgem,
) inherits zabbix::params {
# Determine correct zabbixapi version.

Check warning on line 9 in manifests/zabbixapi.pp

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

indent should be 2 chars and is 4 (check: strict_indent)
case $zabbix_version {

Check warning on line 10 in manifests/zabbixapi.pp

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

indent should be 2 chars and is 4 (check: strict_indent)
/^[56]\.[024]/: {

Check warning on line 11 in manifests/zabbixapi.pp

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

indent should be 4 chars and is 6 (check: strict_indent)
$zabbixapi_version = '5.0.0-alpha1'

Check warning on line 12 in manifests/zabbixapi.pp

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

indent should be 6 chars and is 8 (check: strict_indent)
}

Check warning on line 13 in manifests/zabbixapi.pp

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

indent should be 4 chars and is 6 (check: strict_indent)
default: {

Check warning on line 14 in manifests/zabbixapi.pp

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

indent should be 4 chars and is 6 (check: strict_indent)
fail("Zabbix ${zabbix_version} is not supported!")

Check warning on line 15 in manifests/zabbixapi.pp

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

indent should be 6 chars and is 8 (check: strict_indent)
}

Check warning on line 16 in manifests/zabbixapi.pp

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

indent should be 4 chars and is 6 (check: strict_indent)
}

Check warning on line 17 in manifests/zabbixapi.pp

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

indent should be 2 chars and is 4 (check: strict_indent)

$compile_packages = $facts['os']['family'] ? {

Check warning on line 19 in manifests/zabbixapi.pp

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

indent should be 2 chars and is 4 (check: strict_indent)
'RedHat' => [ 'make', 'gcc-c++', 'rubygems', 'ruby'],

Check failure on line 20 in manifests/zabbixapi.pp

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

there should be no whitespace or a single newline after an opening bracket (check: manifest_whitespace_opening_bracket_after)
'Debian' => [ 'make', 'g++', 'ruby-dev', 'ruby', 'pkg-config',],

Check failure on line 21 in manifests/zabbixapi.pp

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

there should be no whitespace or a single newline after an opening bracket (check: manifest_whitespace_opening_bracket_after)
default => [],
}
ensure_packages($compile_packages)

# Installing the zabbixapi gem package. We need this gem for
# communicating with the zabbix-api. This is way better then
# doing it ourself.
package { 'zabbixapi':
ensure => $zabbixapi_version,
provider => $puppetgem,
}

Check failure on line 32 in manifests/zabbixapi.pp

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

there should be a single space or newline before a closing brace (check: manifest_whitespace_closing_brace_before)

}
12 changes: 0 additions & 12 deletions spec/support/acceptance/prepare_host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,4 @@ def prepare_host

apply_manifest(cleanup_puppet)
shell(cleanup_script)

install_deps = <<-SHELL
$compile_packages = $facts['os']['family'] ? {
'RedHat' => [ 'make', 'gcc-c++', 'rubygems', 'ruby'],
'Debian' => [ 'make', 'g++', 'ruby-dev', 'ruby', 'pkg-config',],
default => [],
}
package { $compile_packages:
ensure => 'present',
}
SHELL
apply_manifest(install_deps)
end

0 comments on commit 44c3feb

Please sign in to comment.