diff --git a/site-modules/profile/lib/facter/ceph_mgr_modules.rb b/site-modules/profile/lib/facter/ceph_mgr_modules.rb new file mode 100644 index 00000000..95842b0b --- /dev/null +++ b/site-modules/profile/lib/facter/ceph_mgr_modules.rb @@ -0,0 +1,9 @@ +require 'json' + +Facter.add('ceph_mgr_modules') do + setcode do + if File.exist?('/var/lib/ceph/mgr') + JSON.parse(Facter::Core::Execution.execute('ceph mgr module ls')) + end + end +end diff --git a/site-modules/profile/manifests/ceph/mon.pp b/site-modules/profile/manifests/ceph/mon.pp index 9c517dc7..bd49dfcc 100644 --- a/site-modules/profile/manifests/ceph/mon.pp +++ b/site-modules/profile/manifests/ceph/mon.pp @@ -1,30 +1,48 @@ # Ceph Monitor profile class profile::ceph::mon { include profile::ceph::base $mon_secret = lookup('ceph::secrets::mon') $mgr_secret = lookup('ceph::secrets::mgr') $client_keys = lookup('ceph::keys') ::ceph::mon {$::hostname: key => $mon_secret, } ::ceph::mgr {$::hostname: key => $mgr_secret, inject_key => true, } ::Ceph::Key { inject => true, inject_as_id => 'mon.', inject_keyring => "/var/lib/ceph/mon/ceph-${::hostname}/keyring", } each($client_keys) |$name, $data| { ::ceph::key {"client.${name}": * => $data, } } + + $enabled_modules = pick( + $::ceph_mgr_modules, + {'enabled_modules' => []}, + )['enabled_modules'] + + unless (member($enabled_modules, 'prometheus')) { + Service<| tag == 'ceph-mgr' |> + -> exec {'ceph mgr enable module prometheus': + path => ['/bin', '/usr/bin'], + } + } + + $fqdn = $::swh_hostname['internal_fqdn'] + + profile::prometheus::export_scrape_config {'ceph': + target => "http://${fqdn}:9283", + } }