Skip to content

Commit

Permalink
Bootstrap agent2 support
Browse files Browse the repository at this point in the history
* Remove some parameters in zabbix agent configuration if it's zabbix
  agent2 package
    * LogRemoteCommands
    * StartAgents
    * MaxLinesPerSecond
    * AllowRoot
    * User
    * LoadModulePath
* Fix EnableRemoteCommands still use on zabbix agentd > 5 but remove on
  agent2

Conflicts:
	manifests/agent.pp
	spec/classes/agent_spec.rb
	spec/acceptance/agent_spec.rb
	templates/zabbix_agentd.conf.erb
  • Loading branch information
fe80 authored and Valantin committed Mar 10, 2024
1 parent db01009 commit f3bcec7
Show file tree
Hide file tree
Showing 7 changed files with 218 additions and 36 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
5. [Usage - Configuration options and additional functionality](#usage)
* [zabbix-server](#usage-zabbix-server)
* [zabbix-agent](#usage-zabbix-agent)
* [zabbix-agent2](#usage-zabbix-agent2)
* [zabbix-proxy](#usage-zabbix-proxy)
* [zabbix-javagateway](#usage-zabbix-javagateway)
* [zabbix-sender](#usage-zabbix-sender)
Expand Down Expand Up @@ -200,6 +201,21 @@ class { 'zabbix::agent':
}
```

### Usage zabbix-agent2

Basic one way of setup, wheter it is monitored by zabbix-server or zabbix-proxy:
```ruby
class { 'zabbix::agent':
agent_configfile_path => '/etc/zabbix/zabbix_agent2.conf',
include_dir => '/etc/zabbix/zabbix_agent2.d',
include_dir_purge => false,
zabbix_package_agent => 'zabbix-agent2',
servicename => 'zabbix-agent2',
manage_startup_script => false,
server => '192.168.20.11',
}
```

### Usage zabbix-proxy

Like the zabbix-server, the zabbix-proxy can also be used in 2 ways:
Expand Down
13 changes: 13 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,19 @@ class { 'zabbix::agent':
}
```

##### Using Zabbix Agent 2

```puppet
class { 'zabbix::agent':
agent_configfile_path => '/etc/zabbix/zabbix_agent2.conf',
include_dir => '/etc/zabbix/zabbix_agent2.d',
include_dir_purge => false,
zabbix_package_agent => 'zabbix-agent2',
servicename => 'zabbix-agent2',
manage_startup_script => false,
}
```

#### Parameters

The following parameters are available in the `zabbix::agent` class:
Expand Down
13 changes: 13 additions & 0 deletions manifests/agent.pp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@
# monitored_by_proxy => 'my_proxy_host',
# server => '192.168.1.1',
# }
#
# @example Using Zabbix Agent 2
# class { 'zabbix::agent':
# agent_configfile_path => '/etc/zabbix/zabbix_agent2.conf',
# include_dir => '/etc/zabbix/zabbix_agent2.d',
# include_dir_purge => false,
# zabbix_package_agent => 'zabbix-agent2',
# servicename => 'zabbix-agent2',
# manage_startup_script => false,
# }
#
# @author Werner Dijkerman [email protected]
class zabbix::agent (
$zabbix_version = $zabbix::params::zabbix_version,
Expand Down Expand Up @@ -219,6 +230,8 @@
String $service_type = $zabbix::params::service_type,
Boolean $manage_startup_script = $zabbix::params::manage_startup_script,
) inherits zabbix::params {
$agent2 = $zabbix_package_agent == 'zabbix-agent2'

# Find if listenip is set. If not, we can set to specific ip or
# to network name. If more than 1 interfaces are available, we
# can find the ipaddress of this specific interface if listenip
Expand Down
144 changes: 121 additions & 23 deletions spec/acceptance/agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,36 @@

supported_versions.each do |version|
describe "zabbix::agent class with zabbix_version #{version}" do
it 'works idempotently with no errors' do
pp = <<-EOS
class { 'zabbix::agent':
server => '192.168.20.11',
zabbix_package_state => 'latest',
zabbix_version => '#{version}',
}
EOS
context 'With minimal parameter' do
it 'works idempotently with no errors' do
pp = <<-EOS
class { 'zabbix::agent':
server => '192.168.20.11',
zabbix_package_state => 'latest',
zabbix_version => '#{version}',
}
EOS

prepare_host
prepare_host

# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

# do some basic checks
describe package('zabbix-agent') do
it { is_expected.to be_installed }
end
# do some basic checks
describe package('zabbix-agent') do
it { is_expected.to be_installed }
end

describe service('zabbix-agent') do
it { is_expected.to be_running }
it { is_expected.to be_enabled }
end
describe service('zabbix-agent') do
it { is_expected.to be_running }
it { is_expected.to be_enabled }
end

describe file('/etc/zabbix/zabbix_agentd.conf') do
its(:content) { is_expected.not_to match %r{ListenIP=} }
describe file('/etc/zabbix/zabbix_agentd.conf') do
its(:content) { is_expected.not_to match %r{ListenIP=} }
end
end

context 'With ListenIP set to an IP-Address' do
Expand All @@ -44,6 +46,7 @@ class { 'zabbix::agent':
zabbix_version => '#{version}',
}
EOS

apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
Expand All @@ -63,6 +66,7 @@ class { 'zabbix::agent':
zabbix_version => '#{version}',
}
EOS

apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
Expand All @@ -77,6 +81,7 @@ class { 'zabbix::agent':
zabbix_version => '#{version}',
}
EOS

apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
Expand All @@ -87,4 +92,97 @@ class { 'zabbix::agent':
end
end
end

describe "zabbix::agent class with agent2 and zabbix_version #{version}" do
# <6.0 agent2 packages are not available for ubuntu 22.04
next if version < '6.0' && default[:platform] =~ %r{ubuntu-22}

before(:context, :clean) do
prepare_host
end

context 'With minimal parameter', :clean do
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'zabbix::agent':
agent_configfile_path => '/etc/zabbix/zabbix_agent2.conf',
include_dir => '/etc/zabbix/zabbix_agent2.d',
include_dir_purge => false,
zabbix_package_agent => 'zabbix-agent2',
servicename => 'zabbix-agent2',
manage_startup_script => false,
server => '192.168.20.11',
zabbix_package_state => 'latest',
zabbix_version => '#{version}',
}
PUPPET
end
end

# do some basic checks
describe package('zabbix-agent2') do
it { is_expected.to be_installed }
end

describe service('zabbix-agent2') do
it { is_expected.to be_running }

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - Rocky 9 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - AlmaLinux 9 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - OracleLinux 9 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - OracleLinux 9 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - AlmaLinux 9 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - CentOS 9 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - Rocky 9 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - CentOS 7 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - OracleLinux 7 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - OracleLinux 7 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - CentOS 7 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - CentOS 9 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - AlmaLinux 9 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - AlmaLinux 8 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - AlmaLinux 8 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - AlmaLinux 9 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - OracleLinux 9 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - Rocky 8 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - AlmaLinux 8 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - OracleLinux 7 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - AlmaLinux 8 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - CentOS 9 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - CentOS 7 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - Rocky 9 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - OracleLinux 9 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - Debian 11 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - Rocky 8 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - Debian 11 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - Debian 11 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - CentOS 8 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - CentOS 9 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - OracleLinux 7 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - Debian 11 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - Rocky 8 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - CentOS 8 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - CentOS 8 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - Ubuntu 20.04 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - Ubuntu 22.04 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - Ubuntu 22.04 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - CentOS 7 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - Ubuntu 20.04 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - Rocky 9 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - Ubuntu 20.04 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - Ubuntu 20.04 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - OracleLinux 8 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - CentOS 8 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - OracleLinux 8 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - OracleLinux 8 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - OracleLinux 8 - Zabbix 5.0

zabbix::agent class with agent2 and zabbix_version 5.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running

Check failure on line 129 in spec/acceptance/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - Rocky 8 - Zabbix 6.0

zabbix::agent class with agent2 and zabbix_version 6.0 With minimal parameter Service "zabbix-agent2" is expected to be running Failure/Error: it { is_expected.to be_running } expected Service "zabbix-agent2" to be running
it { is_expected.to be_enabled }
end

describe file('/etc/zabbix/zabbix_agentd2.conf') do
its(:content) { is_expected.not_to match %r{ListenIP=} }
end
end

context 'With ListenIP set to an IP-Address' do
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'zabbix::agent':
agent_configfile_path => '/etc/zabbix/zabbix_agent2.conf',
include_dir => '/etc/zabbix/zabbix_agent2.d',
include_dir_purge => false,
zabbix_package_agent => 'zabbix-agent2',
servicename => 'zabbix-agent2',
manage_startup_script => false,
server => '192.168.20.11',
zabbix_package_state => 'latest',
listenip => '127.0.0.1',
zabbix_version => '#{version}',
}
PUPPET
end
end

describe file('/etc/zabbix/zabbix_agent2.conf') do
its(:content) { is_expected.to match %r{ListenIP=127.0.0.1} }
end
end

context 'With ListenIP set to lo' do
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'zabbix::agent':
agent_configfile_path => '/etc/zabbix/zabbix_agent2.conf',
include_dir => '/etc/zabbix/zabbix_agent2.d',
include_dir_purge => false,
zabbix_package_agent => 'zabbix-agent2',
servicename => 'zabbix-agent2',
manage_startup_script => false,
server => '192.168.20.11',
zabbix_package_state => 'latest',
listenip => 'lo',
zabbix_version => '#{version}',
}
PUPPET
end

describe file('/etc/zabbix/zabbix_agent2.conf') do
its(:content) { is_expected.to match %r{ListenIP=127.0.0.1} }
end
end
end
end
end
22 changes: 22 additions & 0 deletions spec/classes/agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,28 @@
it { is_expected.to contain_systemd__unit_file('zabbix-agent.service') }
end
end

context 'when zabbix_package_agent is zabbix-agent2' do
let :params do
{
zabbix_package_agent: 'zabbix-agent2', startagents: 1,
maxlinespersecond: 1, allowroot: 1, zabbix_user: 'root',
loadmodulepath: '/tmp', allowkey: 'system.run[*]',
denykey: 'system.run[*]', enableremotecommands: 1,
logremotecommands: 1
}
end

it { is_expected.to contain_package('zabbix-agent2') }

it do
is_expected.not_to contain_file(config_path).with_content(
%r{^(LogRemoteCommands|StartAgents|MaxLinesPerSecond
|AllowRoot|User|LoadModulePath|AllowKey|DenyKey|
EnableRemoteCommands|LogRemoteCommands)}
)
end
end
end
end
end
21 changes: 14 additions & 7 deletions spec/support/acceptance/prepare_host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,28 @@ def prepare_host

apply_manifest <<~PUPPET
$services = $facts['os']['family'] ? {
'RedHat' => ['zabbix-server', 'httpd'],
'Debian' => ['zabbix-server', 'apache2'],
default => [],
'RedHat' => ['zabbix-server', 'httpd', 'zabbix-agent', 'zabbix-agent2'],
'Debian' => ['zabbix-server', 'apache2', 'zabbix-agent', 'zabbix-agent2'],
default => ['zabbix-agent', 'zabbix-agent2'],
}
service { $services:
ensure => stopped
}
$packages = $facts['os']['family'] ? {
'RedHat' => ['zabbix-server-pgsql', 'zabbix-server-pgsql-scl', 'zabbix-web', 'zabbix-web-pgsql', 'zabbix-web-pgsql-scl', 'zabbix-frontend-php', 'zabbix-sql-scripts'],
'Debian' => ['zabbix-server-pgsql', 'zabbix-web-pgsql', 'zabbix-frontend-php', 'zabbix-sql-scripts'],
default => [],
'RedHat' => ['zabbix-server-pgsql', 'zabbix-server-pgsql-scl', 'zabbix-web', 'zabbix-web-pgsql', 'zabbix-web-pgsql-scl', 'zabbix-frontend-php', 'zabbix-sql-scripts', 'zabbix-agent', 'zabbix-agent2'],
'Debian' => ['zabbix-server-pgsql', 'zabbix-web-pgsql', 'zabbix-frontend-php', 'zabbix-sql-scripts', 'zabbix-agent', 'zabbix-agent2'],
default => ['zabbix-agent', 'zabbix-agent2'],
}
$pkg_ensure = $facts['os']['family'] ? {
'RedHat' => purged,
'Debian' => purged,
default => absent,
}
package { $packages:
ensure => purged
ensure => $pkg_ensure,
}
PUPPET

Expand Down
Loading

0 comments on commit f3bcec7

Please sign in to comment.