From be302af945c4959a83da02f2ebc642f99828f7e3 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Tue, 12 Sep 2023 14:43:26 +0200 Subject: [PATCH] add monitoring --- Vagrantfile | 10 +++++ puppet/Puppetfile | 1 + puppet/data/vagrant.yaml | 4 ++ puppet/manifests/site.pp | 5 +++ .../profiles/manifests/monitoring/client.pp | 7 ++++ .../profiles/manifests/monitoring/server.pp | 39 +++++++++++++++++++ vagrant/manifests/default.pp | 4 ++ 7 files changed, 70 insertions(+) create mode 100644 puppet/modules/profiles/manifests/monitoring/client.pp create mode 100644 puppet/modules/profiles/manifests/monitoring/server.pp diff --git a/Vagrantfile b/Vagrantfile index f76fd4e89..f3fb11d63 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -123,4 +123,14 @@ Vagrant.configure("2") do |config| provider.vm.box_url = CENTOS_9_BOX_URL end end + + config.vm.define "monitoring" do |override| + override.vm.hostname = "monitoring" + override.vm.box = "centos/stream9" + + override.vm.provider "libvirt" do |libvirt, provider| + libvirt.memory = "2048" + provider.vm.box_url = CENTOS_9_BOX_URL + end + end end diff --git a/puppet/Puppetfile b/puppet/Puppetfile index ddced18d9..bad2a492e 100644 --- a/puppet/Puppetfile +++ b/puppet/Puppetfile @@ -21,6 +21,7 @@ mod 'puppet/rvm', '2.0.0' mod 'puppet/selinux', '3.4.1' mod 'puppet/systemd', '4.2.0' mod 'puppet/unattended_upgrades', '8.1.0' +mod 'puppet/zabbix', :git => 'https://github.com/voxpupuli/puppet-zabbix', :branch => 'master' mod 'puppetlabs/apache', '8.6.0' mod 'puppetlabs/apt', '9.0.2' mod 'puppetlabs/concat', '7.4.0' diff --git a/puppet/data/vagrant.yaml b/puppet/data/vagrant.yaml index e6e5fb726..b4684858c 100644 --- a/puppet/data/vagrant.yaml +++ b/puppet/data/vagrant.yaml @@ -21,3 +21,7 @@ profiles::jenkins::controller::jenkins_job_builder_username: "admin" profiles::jenkins::node::swap_size_mb: 0 profiles::web::https: false + +profiles::monitoring::server::url: 127.0.0.1 +profiles::monitoring::server::https: false +profiles::monitoring::client::server: 127.0.0.1 diff --git a/puppet/manifests/site.pp b/puppet/manifests/site.pp index 9f87c0e1d..9dea85b6b 100644 --- a/puppet/manifests/site.pp +++ b/puppet/manifests/site.pp @@ -41,3 +41,8 @@ include profiles::base include profiles::web } + +node /^monitoring\d+\.([a-z]+\.)?theforeman\.org$/ { + include profiles::base + include profiles::monitoring::server +} diff --git a/puppet/modules/profiles/manifests/monitoring/client.pp b/puppet/modules/profiles/manifests/monitoring/client.pp new file mode 100644 index 000000000..5a0ce98e1 --- /dev/null +++ b/puppet/modules/profiles/manifests/monitoring/client.pp @@ -0,0 +1,7 @@ +class profiles::monitoring::client ( + Stdlib::Host $server = 'monitoring.theforeman.org', +){ + class { 'zabbix::agent': + server => $server, + } +} diff --git a/puppet/modules/profiles/manifests/monitoring/server.pp b/puppet/modules/profiles/manifests/monitoring/server.pp new file mode 100644 index 000000000..c65f9b6a3 --- /dev/null +++ b/puppet/modules/profiles/manifests/monitoring/server.pp @@ -0,0 +1,39 @@ +class profiles::monitoring::server ( + Stdlib::Host $url = 'monitoring.theforeman.org', + Boolean $https = true, +){ + if $https { + $apache_vhost_custom_params = { + mdomain => true, + } + } else { + $apache_vhost_custom_params = {} + } + + class { 'zabbix::database': } + -> class { 'zabbix::server': } + -> class { 'zabbix::web': + zabbix_url => $url, + manage_resources => true, + apache_use_ssl => $https, + apache_vhost_custom_params => $apache_vhost_custom_params, + } + + class { 'zabbix::agent': + server => '127.0.0.1', + } + + $api_user = getvar('foreman_api_user') + $api_pass = getvar('foreman_api_password') + if $api_user and $api_pass { + $foreman_hosts = foreman::foreman('hosts', '', '20', lookup('foreman_url'), $api_user, $api_pass) + $foreman_hosts.each |$host| { + zabbix_host { $host['name']: + use_ip => false, + port => 10050, + groups => ['Linux servers'], + templates => ['Linux by Zabbix agent'], + } + } + } +} diff --git a/vagrant/manifests/default.pp b/vagrant/manifests/default.pp index 6e2a403c2..4c85cfbde 100644 --- a/vagrant/manifests/default.pp +++ b/vagrant/manifests/default.pp @@ -25,3 +25,7 @@ node /^discourse.*/ { include profiles::discourse } + +node /^monitoring.*/ { + include profiles::monitoring::server +}