diff --git a/lib/facter/mounts.rb b/lib/facter/mounts.rb index 572b5e25..562467ac 100644 --- a/lib/facter/mounts.rb +++ b/lib/facter/mounts.rb @@ -1,59 +1,60 @@ begin Facter.add("mounts") do ignorefs = [ "NFS", "afs", "autofs", "binfmt_misc", "cgroup", "cifs", "coda", + "configfs", "debugfs", "devfs", "devpts", "devtmpfs", "efivarfs", "ftpfs", "fuse", "fuse.gvfsd-fuse", "fuse.lxcfs", "fuse.snapshotfs", "fusectl", "hugetlbfs", "iso9660", "lustre_lite", "mfs", "mqueue", "ncpfs", "nfs", "nfs4", "nfsd", "proc", "pstore", "rpc_pipefs", "securityfs", "shfs", "smbfs", "sysfs", "tmpfs", "udf", "usbfs", ].uniq.sort.join(',') mountpoints = [] Facter::Util::Resolution.exec("findmnt --list --noheadings -o TARGET,SOURCE --invert --types #{ignorefs}").lines.each do |line| mountpoint, source = line.chomp.split # bind mounts if not source.end_with?(']') mountpoints << mountpoint end end setcode do mountpoints end end rescue Exception => _ end diff --git a/manifests/icinga2/agent.pp b/manifests/icinga2/agent.pp index 181a47ef..02d82bcd 100644 --- a/manifests/icinga2/agent.pp +++ b/manifests/icinga2/agent.pp @@ -1,73 +1,77 @@ # Icinga2 agent configuration class profile::icinga2::agent { $features = hiera('icinga2::features') $icinga2_network = hiera('icinga2::network') $hiera_host_vars = hiera_hash('icinga2::host::vars') $parent_zone = hiera('icinga2::parent_zone') $parent_endpoints = hiera('icinga2::parent_endpoints') include profile::icinga2::objects::agent_checks + $check_mounts = $::mounts.filter |$mount| { + $mount !~ /^\/srv\/containers/ + } + $local_host_vars = { disks => hash(flatten( - $::mounts.map |$mount| { + $check_mounts.map |$mount| { ["disk ${mount}", {disk_partitions => $mount}] }, - )), + )), plugins => keys($profile::icinga2::objects::agent_checks::plugins), } class {'::icinga2': confd => true, features => $features, } class { '::icinga2::feature::api': accept_config => true, accept_commands => true, zones => { 'ZoneName' => { endpoints => ['NodeName'], parent => $parent_zone, }, }, } create_resources('::icinga2::object::endpoint', $parent_endpoints) ::icinga2::object::zone {$parent_zone: endpoints => keys($parent_endpoints), } @@::icinga2::object::endpoint {$::fqdn: target => "/etc/icinga2/zones.d/${parent_zone}/${::fqdn}.conf", } @@::icinga2::object::zone {$::fqdn: endpoints => [$::fqdn], parent => $parent_zone, target => "/etc/icinga2/zones.d/${parent_zone}/${::fqdn}.conf", } @@::icinga2::object::host {$::fqdn: address => ip_for_network($icinga2_network), display_name => $::fqdn, check_command => 'hostalive', vars => deep_merge($local_host_vars, $hiera_host_vars), target => "/etc/icinga2/zones.d/${parent_zone}/${::fqdn}.conf", } icinga2::object::zone { 'global-templates': global => true, } file {'/etc/icinga2/conf.d': ensure => directory, owner => 'nagios', group => 'nagios', mode => '0755', purge => true, recurse => true, tag => 'icinga2::config::file', } }