Agent
puppet-control-repo/development/site/profile/manifests/zabbix/agent.pp
# == Class: profile::zabbix::agent
#
class profile::zabbix::agent($server) {
class { '::zabbix::agent':
server => $server,
serveractive => $server,
manage_repo => false,
#zabbix_version => '3.2.1', # uncomment once servers of the same version are deployed; and remove the line below
zabbix_version => '2.4.8',
enableremotecommands => 1,
logremotecommands => 1,
logfile => '/var/log/zabbix/zabbix_agentd.log',
startagents => 1,
buffersend => 300,
hostmetadataitem => 'system.run[jq -c .info.vm external-sys.json]',
}
}
Proxy
puppet-control-repo/development/site/profile/manifests/zabbix/zabbix_proxy.pp
# == Class: profile::zabbix::zabbix_proxy
#
# Profile that installs and configures zabbix proxy
# default module settings can be found in https://github.com/voxpupuli/puppet-zabbix/blob/master/manifests/params.pp
# default site settings, which override these, can be found in puppet-control-repo/blob/development/site/profile/manifests/zabbix/zabbix_params.pp ()
class profile::zabbix::zabbix_proxy {
class { '::mysql::client' : }
class { 'profile::zabbix::zabbix_params': }
class { '::zabbix::proxy' :
zabbix_server_host => $profile::zabbix::zabbix_params::zabbix_server_host,
zabbix_version => $profile::zabbix::zabbix_params::zabbix_version,
database_type => $profile::zabbix::zabbix_params::zabbix_db_type,
manage_repo => $profile::zabbix::zabbix_params::zabbix_manage_repo,
configfrequency => '120',
database_user => $profile::zabbix::zabbix_params::zabbix_db_user,
database_password => $profile::zabbix::zabbix_params::zabbix_db_pass,
datasenderfrequency => '10',
logslowqueries => '1',
offlinebuffer => '4',
manage_database => $profile::zabbix::zabbix_params::zabbix_manage_db,
}
# class { 'zabbix::database':
# database_type => 'mysql',
# zabbix_type => 'proxy',
# zabbix_proxy_ip => '127.0.0.1',
# zabbix_proxy => 'localhost',
# database_name => 'zabbix_proxy',
# database_user => 'root',
# database_password => $proxy_database_password,
# }
}
Server
puppet-control-repo/development/site/profile/manifests/zabbix/zabbix_server.pp
# == Class: profile::zabbix::zabbix_server
#
# Profile that installs and configures zabbix server
class profile::zabbix::zabbix_server {
class { '::mysql::client' : }
class { '::zabbix::server' :
database_host => $profile::zabbix::zabbix_params::zabbix_db,
database_type => $profile::zabbix::zabbix_params::zabbix_db_type,
database_user => $profile::zabbix::zabbix_params::zabbix_db_user,
database_password => $profile::zabbix::zabbix_params::zabbix_db_pass,
logslowqueries => '1', # True
manage_database => $profile::zabbix::zabbix_params::zabbix_manage_db,
manage_repo => $profile::zabbix::zabbix_params::zabbix_manage_repo,
zabbix_version => $profile::zabbix::zabbix_params::zabbix_version,
logfilesize => '128', # MB
startpollers => '1', # default of 5 is unnecessary on the server as the proxy is doing this work
# startsnmptrapper => '1', # uncomment this line to be able to receive SNMP traps from network equipment
}
}
Web
puppet-control-repo/development/site/profile/manifests/zabbix/zabbix_web.pp
# == Class: profile::zabbix::zabbix_web
# We are avoiding using the Puppet module for this profile as it does not support RHEL 6
# When the OS is upgraded you can use the commented out code as a base to configure the zabbix front end
# Profile that installs and configures zabbix front end
# Below is for RHEL/CentOS 7 and above
# class profile::zabbix::zabbix_web( $zabbix_url, $zabbix_server, $zabbix_db ) {
# class { 'apache:' :
# mpm_module => 'prefork',
# }
# class { 'apache::mod::php' : }
# class { '::zabbix::web' :
# zabbix_url => $zabbix_url,
# zabbix_server => $zabbix_server,
# database_host => $zabbix_db,
# database_type => 'mysql',
# manage_repo => false,
# }
#}
class profile::zabbix::zabbix_web {
class { 'apache': mpm_module => 'prefork', }
class { 'apache::mod::php': }
class { 'profile::zabbix::zabbix_params': }
class { 'zabbix::web':
database_host => $profile::zabbix::zabbix_params::zabbix_db,
database_type => $profile::zabbix::zabbix_params::zabbix_db_type,
database_user => $profile::zabbix::zabbix_params::zabbix_db_user,
database_password => $profile::zabbix::zabbix_params::zabbix_db_pass,
zabbix_version => $profile::zabbix::zabbix_params::zabbix_version,
zabbix_url => $profile::zabbix::zabbix_params::zabbix_url,
zabbix_server => $profile::zabbix::zabbix_params::zabbix_server_host,
zabbix_timezone => $profile::zabbix::zabbix_params::zabbix_timezone,
zabbix_api_user => $profile::zabbix::zabbix_params::zabbix_api_user,
zabbix_api_pass => $profile::zabbix::zabbix_params::zabbix_api_pass,
manage_repo => $profile::zabbix::zabbix_params::zabbix_manage_repo,
default_vhost => true,
}
}
DB
puppet-control-repo/development/site/profile/manifests/zabbix/zabbix_db_master.pp
# == Class: profile::zabbix::zabbix_srv_db_mstr
#
# Profile that sets up the master DB for Zabbix Server
class profile::zabbix::zabbix_srv_db_mstr( $zabbix_server_ste, $zabbix_server_sdc, $zabbix_web, $replicator_pw ) {
class { 'profile::zabbix::zabbix_params': }
$db_mstr_overrides = {
'mysqld' => {
#'default_password_lifetime' => 0, # this is trying to work around the issue in 5.7 where authentication fails and first manual connection insists "You must reset your password using ALTER USER statement before executing this statement"
'server-id' => 1,
'log-bin' => '/var/log/mysql/master-bin.log',
'expire_logs_days' => 1,
'binlog_format' => 'MIXED',
'binlog-do-db' => 'zabbix-server',
'symbolic-links' => 0,
'transaction_isolation' => 'READ-COMMITTED',
'innodb_buffer_pool_size' => $innodb_buffer_pool_size,
'innodb_file_per_table' => true,
'innodb_doublewrite' => false,
'innodb_flush_log_at_trx_commit' => 2,
'innodb_flush_method' => 'O_DIRECT',
'innodb_max_dirty_pages_pct' => 0,
'max_allowed_packet' => '64M',
'event_scheduler' => 'ON',
},
'mysqld_safe' => {
'log-error' => '/var/log/mysqld.log',
'pid-file' => '/var/run/mysqld/mysqld.pid',
}
}
class { '::mysql::server' :
#Sets the values in /etc/my.cnf to enable efficient use of mysql database by zabbix
override_options => $db_mstr_overrides,
package_name => $profile::zabbix::zabbix_params::mysql_pkg_name,
package_ensure => $profile::zabbix::zabbix_params::mysql_version,
#root_password => $profile::zabbix::zabbix_params::zabbix_db_pass,
users => {
"replicator@$zabbix_server_ste" => {
ensure => 'present',
max_connections_per_hour => '0',
max_queries_per_hour => '0',
max_updates_per_hour => '0',
max_user_connections => '0',
password_hash => "$replicator_pw",
},
"replicator@$zabbix_server_sdc" => {
ensure => 'present',
max_connections_per_hour => '0',
max_queries_per_hour => '0',
max_updates_per_hour => '0',
max_user_connections => '0',
password_hash => "$replicator_pw",
},
},
grants => {
"replicator@$zabbix_server_ste/*.*" => {
ensure => 'present',
#options => ['GRANT'],
privileges => ['REPLICATION SLAVE','REPLICATION CLIENT'],
table => '*.*',
user => "replicator@$zabbix_server_ste",
},
"replicator@$zabbix_server_sdc/*.*" => {
ensure => 'present',
#options => ['GRANT'],
privileges => ['REPLICATION SLAVE','REPLICATION CLIENT'],
table => '*.*',
user => "replicator@$zabbix_server_sdc",
},
},
}
class { '::zabbix::database' :
manage_database => true,
database_schema_path => "/usr/share/doc/zabbix-server-mysql-${profile::zabbix::zabbix_params::zabbix_version}/",
database_type => $profile::zabbix::zabbix_params::zabbix_db_type,
#database_user => $profile::zabbix::zabbix_params::zabbix_db_user,
#database_password => $profile::zabbix::zabbix_params::zabbix_db_pass,
zabbix_server => $zabbix_server, # would be ideal to use some Puppet fact here somehow. Unless the hostname option is set to the DNS CNAME in zabbix_server.conf
zabbix_web => $zabbix_web, # would be ideal to use some Puppet fact here somehow. Unless PHP config can be updated to use the DNS CNAME
}
# Lay down the zql files that allow the mysql database to manage partitions
file { '/home/sql' :
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755'
}
file { '/home/sql/zabbix_partitioning.sql' :
ensure => present,
owner => 'root',
group => 'root',
mode => '0750',
source => 'puppet:///custom_files/sql/zabbix_partitioning.sql',
require => Class['::zabbix::database'],
}
file { '/home/sql/zabbix_partitioning_event.sql' :
ensure => present,
owner => 'root',
group => 'root',
mode => '0750',
source => 'puppet:///custom_config_files/sql/zabbix_partitioning_event.sql',
require => Class['::zabbix::database'],
}
# run the sql commands if the files change to enable zabbix partitioning
# exec { 'partitioning' :
# command => 'cat zabbix_partitioning.sql | mysql -uroot zabbix_server',
# cwd => '/home/sql',
# path => ['/bin','/usr/bin'],
# subscribe => File['/home/sql/zabbix_partitioning.sql'],
# refreshonly => true,
# }
# exec { 'partitioning_event' :
# command => 'cat zabbix_partitioning_event.sql | mysql -uroot zabbix_server',
# cwd => '/home/sql',
# path => ['/bin','/usr/bin'],
# subscribe => File['/home/sql/zabbix_partitioning_event.sql'],
# refreshonly => true,
# }
}