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 zabbix-agent support on windows #675

Merged
merged 1 commit into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ fixtures:
ruby: https://github.com/puppetlabs/puppetlabs-ruby.git
systemd: https://github.com/camptocamp/puppet-systemd.git
selinux: https://github.com/voxpupuli/puppet-selinux.git
chocolatey: https://github.com/puppetlabs/puppetlabs-chocolatey.git
yumrepo_core:
repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git
puppet_version: ">= 6.0.0"
Expand Down
39 changes: 29 additions & 10 deletions manifests/agent.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
# [*manage_repo*]
# When true, it will create repository for installing the agent.
#
# [*manage_choco*]
# When true on windows, it will use chocolatey to install the agent.
# The module chocolatey is required https://forge.puppet.com/puppetlabs/chocolatey.
#
# [*zabbix_package_provider*]
# Which package's provider to use to install the agent.
# It is undef for all linux os and set to 'chocolatey' on windows.
#
# [*manage_resources*]
# When true, it will export resources to something like puppetdb.
# When set to true, you'll need to configure 'storeconfigs' to make
Expand Down Expand Up @@ -230,6 +238,8 @@
$zabbix_version = $zabbix::params::zabbix_version,
$zabbix_package_state = $zabbix::params::zabbix_package_state,
$zabbix_package_agent = $zabbix::params::zabbix_package_agent,
Optional[String[1]] $zabbix_package_provider = $zabbix::params::zabbix_package_provider,
Boolean $manage_choco = $zabbix::params::manage_choco,
Boolean $manage_firewall = $zabbix::params::manage_firewall,
Boolean $manage_repo = $zabbix::params::manage_repo,
Boolean $manage_resources = $zabbix::params::manage_resources,
Expand Down Expand Up @@ -269,12 +279,12 @@
Optional[Array] $zabbix_alias = $zabbix::params::agent_zabbix_alias,
$timeout = $zabbix::params::agent_timeout,
$allowroot = $zabbix::params::agent_allowroot,
$zabbix_user = $zabbix::params::agent_zabbix_user,
Optional[String[1]] $zabbix_user = $zabbix::params::agent_zabbix_user,
$include_dir = $zabbix::params::agent_include,
$include_dir_purge = $zabbix::params::agent_include_purge,
$unsafeuserparameters = $zabbix::params::agent_unsafeuserparameters,
$userparameter = $zabbix::params::agent_userparameter,
$loadmodulepath = $zabbix::params::agent_loadmodulepath,
Optional[String[1]] $loadmodulepath = $zabbix::params::agent_loadmodulepath,
$loadmodule = $zabbix::params::agent_loadmodule,
$tlsaccept = $zabbix::params::agent_tlsaccept,
$tlscafile = $zabbix::params::agent_tlscafile,
Expand All @@ -286,8 +296,8 @@
$tlspskidentity = $zabbix::params::agent_tlspskidentity,
$tlsservercertissuer = $zabbix::params::agent_tlsservercertissuer,
$tlsservercertsubject = $zabbix::params::agent_tlsservercertsubject,
String $agent_config_owner = $zabbix::params::agent_config_owner,
String $agent_config_group = $zabbix::params::agent_config_group,
Optional[String[1]] $agent_config_owner = $zabbix::params::agent_config_owner,
Optional[String[1]] $agent_config_group = $zabbix::params::agent_config_group,
Boolean $manage_selinux = $zabbix::params::manage_selinux,
Array[String] $selinux_require = $zabbix::params::selinux_require,
Hash[String, Array] $selinux_rules = $zabbix::params::selinux_rules,
Expand Down Expand Up @@ -380,11 +390,20 @@
}
}

# Installing the package
package { $zabbix_package_agent:
ensure => $zabbix_package_state,
require => Class['zabbix::repo'],
tag => 'zabbix',
if $facts['kernel'] == 'windows' and $manage_choco {
package { $zabbix_package_agent:
ensure => $zabbix_version,
provider => $zabbix_package_provider,
tag => 'zabbix',
}
}
else {
# Installing the package
package { $zabbix_package_agent:
ensure => $zabbix_package_state,
require => Class['zabbix::repo'],
tag => 'zabbix',
}
}

# Ensure that the correct config file is used.
Expand All @@ -400,7 +419,7 @@
}
}

if $agent_configfile_path != '/etc/zabbix/zabbix_agentd.conf' {
if $agent_configfile_path != '/etc/zabbix/zabbix_agentd.conf' and $facts['kernel'] != 'windows' {
file { '/etc/zabbix/zabbix_agentd.conf':
ensure => absent,
require => Package[$zabbix_package_agent],
Expand Down
186 changes: 116 additions & 70 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,83 +14,127 @@
# It seems that ubuntu has an different fping path...
case $facts['os']['name'] {
'Ubuntu', 'Debian' : {
$server_fpinglocation = '/usr/bin/fping'
$server_fping6location = '/usr/bin/fping6'
$proxy_fpinglocation = '/usr/bin/fping'
$proxy_fping6location = '/usr/bin/fping6'
$manage_repo = true
$zabbix_package_agent = 'zabbix-agent'
$agent_configfile_path = '/etc/zabbix/zabbix_agentd.conf'
$agent_config_owner = 'zabbix'
$agent_zabbix_user = 'zabbix'
$agent_config_group = 'zabbix'
$agent_pidfile = '/var/run/zabbix/zabbix_agentd.pid'
$agent_servicename = 'zabbix-agent'
$server_zabbix_user = 'zabbix'
$server_fpinglocation = '/usr/bin/fping'
$server_fping6location = '/usr/bin/fping6'
$proxy_fpinglocation = '/usr/bin/fping'
$proxy_fping6location = '/usr/bin/fping6'
$manage_repo = true
$manage_choco = false
$zabbix_package_agent = 'zabbix-agent'
$agent_configfile_path = '/etc/zabbix/zabbix_agentd.conf'
$agent_config_owner = 'zabbix'
$agent_zabbix_user = 'zabbix'
$agent_config_group = 'zabbix'
$agent_pidfile = '/var/run/zabbix/zabbix_agentd.pid'
$agent_servicename = 'zabbix-agent'
$agent_include = '/etc/zabbix/zabbix_agentd.d'
$server_zabbix_user = 'zabbix'
$zabbix_package_provider = undef
$agent_loadmodulepath = '/usr/lib/modules'
}
'Archlinux': {
$server_fpinglocation = '/usr/bin/fping'
$server_fping6location = '/usr/bin/fping6'
$proxy_fpinglocation = '/usr/bin/fping'
$proxy_fping6location = '/usr/bin/fping6'
$manage_repo = false
$zabbix_package_agent = 'zabbix-agent'
$agent_configfile_path = '/etc/zabbix/zabbix_agentd.conf'
$agent_config_owner = 'zabbix-agent'
$agent_zabbix_user = 'zabbix-agent'
$agent_config_group = 'zabbix-agent'
$agent_pidfile = undef
$agent_servicename = 'zabbix-agent'
$server_zabbix_user = 'zabbix-server'
$server_fpinglocation = '/usr/bin/fping'
$server_fping6location = '/usr/bin/fping6'
$proxy_fpinglocation = '/usr/bin/fping'
$proxy_fping6location = '/usr/bin/fping6'
$manage_repo = false
$manage_choco = false
$zabbix_package_agent = 'zabbix-agent'
$agent_configfile_path = '/etc/zabbix/zabbix_agentd.conf'
$agent_config_owner = 'zabbix-agent'
$agent_zabbix_user = 'zabbix-agent'
$agent_config_group = 'zabbix-agent'
$agent_pidfile = undef
$agent_servicename = 'zabbix-agent'
$agent_include = '/etc/zabbix/zabbix_agentd.d'
$server_zabbix_user = 'zabbix-server'
$zabbix_package_provider = undef
$agent_loadmodulepath = '/usr/lib/modules'
}
'Fedora': {
$server_fpinglocation = '/usr/sbin/fping'
$server_fping6location = '/usr/sbin/fping6'
$proxy_fpinglocation = '/usr/sbin/fping'
$proxy_fping6location = '/usr/sbin/fping6'
$manage_repo = false
$zabbix_package_agent = 'zabbix-agent'
$agent_configfile_path = '/etc/zabbix_agentd.conf'
$agent_config_owner = 'zabbix'
$agent_zabbix_user = 'zabbix'
$agent_config_group = 'zabbix'
$agent_pidfile = '/var/run/zabbix/zabbix_agentd.pid'
$agent_servicename = 'zabbix-agent'
$server_zabbix_user = 'zabbix'
$server_fpinglocation = '/usr/sbin/fping'
$server_fping6location = '/usr/sbin/fping6'
$proxy_fpinglocation = '/usr/sbin/fping'
$proxy_fping6location = '/usr/sbin/fping6'
$manage_repo = false
$manage_choco = false
$zabbix_package_agent = 'zabbix-agent'
$agent_configfile_path = '/etc/zabbix_agentd.conf'
$agent_config_owner = 'zabbix'
$agent_zabbix_user = 'zabbix'
$agent_config_group = 'zabbix'
$agent_pidfile = '/var/run/zabbix/zabbix_agentd.pid'
$agent_servicename = 'zabbix-agent'
$agent_include = '/etc/zabbix/zabbix_agentd.d'
$server_zabbix_user = 'zabbix'
$zabbix_package_provider = undef
$agent_loadmodulepath = '/usr/lib/modules'
}
'Gentoo': {
$server_fpinglocation = '/usr/sbin/fping'
$server_fping6location = '/usr/sbin/fping6'
$proxy_fpinglocation = '/usr/sbin/fping'
$proxy_fping6location = '/usr/sbin/fping6'
$manage_repo = false
$zabbix_package_agent = 'zabbix'
$agent_configfile_path = '/etc/zabbix/zabbix_agentd.conf'
$agent_config_owner = 'zabbix'
$agent_zabbix_user = 'zabbix'
$agent_config_group = 'zabbix'
$agent_pidfile = '/var/run/zabbix/zabbix_agentd.pid'
$agent_servicename = 'zabbix-agentd'
$server_zabbix_user = 'zabbix'
$server_fpinglocation = '/usr/sbin/fping'
$server_fping6location = '/usr/sbin/fping6'
$proxy_fpinglocation = '/usr/sbin/fping'
$proxy_fping6location = '/usr/sbin/fping6'
$manage_repo = false
$manage_choco = false
$zabbix_package_agent = 'zabbix'
$agent_configfile_path = '/etc/zabbix/zabbix_agentd.conf'
$agent_config_owner = 'zabbix'
$agent_zabbix_user = 'zabbix'
$agent_config_group = 'zabbix'
$agent_pidfile = '/var/run/zabbix/zabbix_agentd.pid'
$agent_servicename = 'zabbix-agentd'
$agent_include = '/etc/zabbix/zabbix_agentd.d'
$server_zabbix_user = 'zabbix'
$zabbix_package_provider = undef
$agent_loadmodulepath = '/usr/lib/modules'
}
'windows': {
$manage_repo = false
$manage_choco = true
$zabbix_package_agent = 'zabbix-agent'
$zabbix_package_provider = 'chocolatey'
$agent_configfile_path = 'C:/ProgramData/zabbix/zabbix_agentd.conf'
$agent_config_owner = undef
$agent_zabbix_user = undef
$agent_config_group = undef
$agent_pidfile = 'C:/ProgramData/zabbix/zabbix_agentd.pid'
$agent_servicename = 'Zabbix Agent'
$agent_include = 'C:/ProgramData/zabbix/zabbix_agentd.d'
$agent_loadmodulepath = undef
}
default : {
$server_fpinglocation = '/usr/sbin/fping'
$server_fping6location = '/usr/sbin/fping6'
$proxy_fpinglocation = '/usr/sbin/fping'
$proxy_fping6location = '/usr/sbin/fping6'
$manage_repo = true
$zabbix_package_agent = 'zabbix-agent'
$agent_configfile_path = '/etc/zabbix/zabbix_agentd.conf'
$agent_config_owner = 'zabbix'
$agent_zabbix_user = 'zabbix'
$agent_config_group = 'zabbix'
$agent_pidfile = '/var/run/zabbix/zabbix_agentd.pid'
$agent_servicename = 'zabbix-agent'
$server_zabbix_user = 'zabbix'
$server_fpinglocation = '/usr/sbin/fping'
$server_fping6location = '/usr/sbin/fping6'
$proxy_fpinglocation = '/usr/sbin/fping'
$proxy_fping6location = '/usr/sbin/fping6'
$manage_repo = true
$manage_choco = false
$zabbix_package_agent = 'zabbix-agent'
$agent_configfile_path = '/etc/zabbix/zabbix_agentd.conf'
$agent_config_owner = 'zabbix'
$agent_zabbix_user = 'zabbix'
$agent_config_group = 'zabbix'
$agent_pidfile = '/var/run/zabbix/zabbix_agentd.pid'
$agent_include = '/etc/zabbix/zabbix_agentd.d'
$agent_servicename = 'zabbix-agent'
$server_zabbix_user = 'zabbix'
$zabbix_package_provider = undef
$agent_loadmodulepath = '/usr/lib/modules'
}
}

# Zabbix overall params. Is used by all components.
$zabbix_version = downcase($facts['kernel']) ? {
'windows' => '4.4.5',
default => '3.4',
}

$manage_startup_script = downcase($facts['kernel']) ? {
'windows' => false,
default => true,
}

$zabbix_package_state = 'present'
$zabbix_proxy = 'localhost'
$zabbix_proxy_ip = '127.0.0.1'
Expand All @@ -99,12 +143,10 @@
$zabbix_template_dir = '/etc/zabbix/imported_templates'
$zabbix_timezone = 'Europe/Amsterdam'
$zabbix_url = 'localhost'
$zabbix_version = '3.4'
$zabbix_web = 'localhost'
$zabbix_web_ip = '127.0.0.1'
$manage_database = true
$manage_service = true
$manage_startup_script = true
$default_vhost = false
$manage_firewall = false
$manage_apt = true
Expand Down Expand Up @@ -241,12 +283,10 @@
$agent_hostnameitem = 'system.hostname'
$agent_hostinterface = undef
$agent_hostinterfaceitem = undef
$agent_include = '/etc/zabbix/zabbix_agentd.d'
$agent_include_purge = true
$agent_listenip = undef
$agent_listenport = '10050'
$agent_loadmodule = undef
$agent_loadmodulepath = '/usr/lib/modules'
$agent_logremotecommands = '0'
$agent_maxlinespersecond = '100'
$agent_refreshactivechecks = '120'
Expand Down Expand Up @@ -284,7 +324,13 @@
$agent_logtype = 'system'
$agent_logfile = undef
$agent_logfilesize = undef
} else {
}
elsif $facts['kernel'] == 'windows' {
$agent_logtype = 'file'
$agent_logfile = 'C:/ProgramData/zabbix/zabbix_agentd.log'
$agent_logfilesize = '100'
}
else {
$agent_logtype = 'file'
$agent_logfile = '/var/log/zabbix/zabbix_agentd.log'
$agent_logfilesize = '100'
Expand Down
11 changes: 9 additions & 2 deletions manifests/startup.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
assert_type(Boolean, $manage_database)
}
default: {
fail('we currently only spport a title that contains agent or server')
fail('we currently only support a title that contains agent or server')
}
}
# provided by camp2camp/systemd
Expand All @@ -56,7 +56,14 @@
mode => '0755',
content => template("zabbix/${name}-${osfamily_downcase}.init.erb"),
}
} elsif ($facts['os']['family'] == 'windows') {
exec { "install_agent_${name}":
command => "& 'C:\\Program Files\\Zabbix Agent\\zabbix_agentd.exe' --config ${agent_configfile_path} --install",
onlyif => "if (Get-WmiObject -Class Win32_Service -Filter \"Name='${name}'\"){exit 1}",
provider => powershell,
notify => Service[$name],
}
} else {
fail('We currently only support Debian and RedHat osfamily as non-systemd')
fail('We currently only support Debian, Redhat and Windows osfamily as non-systemd')
}
}
8 changes: 8 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@
"9",
"10"
]
},
{
"operatingsystem": "windows",
"operatingsystemrelease": [
"2012",
"2012 R2",
"2016"
]
}
]
}
Loading