puppet-prod/modules/exporters/manifests/node_exporter.pp
Ben Vincent 23dd962d89 feat: allow specifying consul addr for exporters
- ensure frr/node exporter reachable on hosts with loopbacks
2025-08-09 17:08:38 +10:00

83 lines
2.1 KiB
Puppet

class exporters::node_exporter (
Boolean $enable = false,
String $user = 'node_exporter',
String $group = 'node_exporter',
Boolean $manage_user = true,
Boolean $manage_service = true,
Stdlib::Host $addr = $facts['networking']['ip'],
Stdlib::Port $port = 9100,
Stdlib::Absolutepath $exec_path = '/usr/bin/node_exporter',
Boolean $cleanup_old_node_exporter = false,
){
if $cleanup_old_node_exporter {
# remove the symlink
file {'/usr/local/bin/node_exporter':
ensure => absent
}
# remove the /opt/node_exporter-1.8.1.linux-amd64 directory
file {'/opt/node_exporter-1.8.1.linux-amd64':
ensure => absent,
recurse => true,
force => true,
}
}
if $enable {
# install required package
package {'node_exporter':
ensure => installed,
}
# manage the user/group
if $manage_user {
group { $group:
ensure => present,
}
user { $user:
ensure => present,
shell => '/usr/sbin/nologin',
groups => $group,
managehome => true,
}
}
# manage the systemd service
if $manage_service {
# Use these in notifications or file resources
systemd::unit_file { 'node_exporter.service':
content => template('exporters/node_exporter.service.erb'),
enable => true,
active => true,
subscribe => Package['node_exporter'],
}
}
# manage consul service
consul::service { 'node_exporter':
service_name => 'node_exporter',
address => $addr,
port => $port,
tags => [
'metrics',
'metrics_scheme=http',
'metrics_job=node',
],
checks => [
{
id => 'node_exporter_http_check',
name => 'node_exporter HTTP Check',
http => "http://${facts['networking']['fqdn']}:${port}",
method => 'GET',
tls_skip_verify => true,
interval => '10s',
timeout => '1s',
},
],
}
}
}