diff --git a/manifests/icinga2/objects.pp b/manifests/icinga2/objects.pp index fe62740..ef19947 100644 --- a/manifests/icinga2/objects.pp +++ b/manifests/icinga2/objects.pp @@ -1,12 +1,13 @@ # Icinga2 object definitions class profile::icinga2::objects { include profile::icinga2::objects::templates include profile::icinga2::objects::commands include profile::icinga2::objects::users include profile::icinga2::objects::notifications include profile::icinga2::objects::timeperiods include profile::icinga2::objects::common_checks include profile::icinga2::objects::static_checks include profile::icinga2::objects::agent_checks + include profile::icinga2::objects::exported_checks } diff --git a/manifests/icinga2/objects/exported_checks.pp b/manifests/icinga2/objects/exported_checks.pp new file mode 100644 index 0000000..cef3129 --- /dev/null +++ b/manifests/icinga2/objects/exported_checks.pp @@ -0,0 +1,4 @@ +# Exported checks on the icinga agents +class profile::icinga2::objects::exported_checks { + ::Icinga2::Object::Service <<| tag == 'icinga2::exported' |>> +} diff --git a/manifests/swh/deploy/storage.pp b/manifests/swh/deploy/storage.pp index 804dc97..ad6a4d1 100644 --- a/manifests/swh/deploy/storage.pp +++ b/manifests/swh/deploy/storage.pp @@ -1,57 +1,94 @@ # Deployment of the swh.storage.api server class profile::swh::deploy::storage { $conf_directory = hiera('swh::deploy::storage::conf_directory') $conf_file = hiera('swh::deploy::storage::conf_file') $user = hiera('swh::deploy::storage::user') $group = hiera('swh::deploy::storage::group') $swh_packages = ['python3-swh.storage'] - $backend_listen_address = hiera('swh::deploy::storage::backend::listen') + $backend_listen_host = hiera('swh::deploy::storage::backend::listen::host') + $backend_listen_port = hiera('swh::deploy::storage::backend::listen::port') + $backend_listen_address = "${backend_listen_host}:${backend_listen_port}" + $backend_workers = hiera('swh::deploy::storage::backend::workers') $backend_http_keepalive = hiera('swh::deploy::storage::backend::http_keepalive') $backend_http_timeout = hiera('swh::deploy::storage::backend::http_timeout') $backend_reload_mercy = hiera('swh::deploy::storage::backend::reload_mercy') $storage_config = hiera('swh::deploy::storage::config') include ::gunicorn package {$swh_packages: ensure => latest, require => Apt::Source['softwareheritage'], notify => Service['gunicorn-swh-storage'], } file {$conf_directory: ensure => directory, owner => 'root', group => $group, mode => '0755', } file {$conf_file: ensure => present, owner => 'root', group => $group, mode => '0640', content => inline_template("<%= @storage_config.to_yaml %>\n"), notify => Service['gunicorn-swh-storage'], } ::gunicorn::instance {'swh-storage': ensure => enabled, user => $user, group => $group, executable => 'swh.storage.api.server:run_from_webserver', settings => { bind => $backend_listen_address, workers => $backend_workers, worker_class => 'sync', timeout => $backend_http_timeout, graceful_timeout => $backend_reload_mercy, keepalive => $backend_http_keepalive, } } + + $icinga_checks_file = '/etc/icinga2/conf.d/exported-checks.conf' + + @@::icinga2::object::service {"swh-storage api (localhost on ${::fqdn})": + service_name => 'swh-storage api (localhost)', + import => ['generic-service'], + host_name => $::fqdn, + check_command => 'http', + command_endpoint => $::fqdn, + vars => { + http_address => '127.0.0.1', + http_port => $backend_listen_port, + http_uri => '/', + http_string => 'SWH Storage API server', + }, + target => $icinga_checks_file, + tag => 'icinga2::exported', + } + + if $backend_listen_host != '127.0.0.1' { + @@::icinga2::object::service {"swh-storage api (remote on ${::fqdn})": + service_name => 'swh-storage api (remote)', + import => ['generic-service'], + host_name => $::fqdn, + check_command => 'http', + vars => { + http_port => $backend_listen_port, + http_uri => '/', + http_string => 'SWH Storage API server', + }, + target => $icinga_checks_file, + tag => 'icinga2::exported', + } + } }