70 lines
1.8 KiB
Puppet
70 lines
1.8 KiB
Puppet
class exporters::frr_exporter (
|
|
Boolean $enable = false,
|
|
String $user = 'frr_exporter',
|
|
String $group = 'frr_exporter',
|
|
Boolean $manage_user = true,
|
|
Boolean $manage_service = true,
|
|
Stdlib::Host $addr = $facts['networking']['ip'],
|
|
Stdlib::Port $port = 9342,
|
|
Stdlib::Absolutepath $exec_path = '/usr/bin/frr_exporter',
|
|
Stdlib::Absolutepath $socket_dir = '/var/run/frr',
|
|
){
|
|
|
|
if $enable {
|
|
|
|
# install required package
|
|
package {'frr_exporter':
|
|
ensure => installed,
|
|
}
|
|
|
|
# manage the user/group
|
|
if $manage_user {
|
|
group { $group:
|
|
ensure => present,
|
|
}
|
|
|
|
user { $user:
|
|
ensure => present,
|
|
shell => '/usr/sbin/nologin',
|
|
groups => [$group, 'frrvty'],
|
|
managehome => true,
|
|
}
|
|
}
|
|
|
|
# manage the systemd service
|
|
if $manage_service {
|
|
|
|
# Use these in notifications or file resources
|
|
systemd::unit_file { 'frr_exporter.service':
|
|
content => template('exporters/frr_exporter.service.erb'),
|
|
enable => true,
|
|
active => true,
|
|
subscribe => Package['frr_exporter'],
|
|
}
|
|
}
|
|
|
|
# manage consul service
|
|
consul::service { 'frr_exporter':
|
|
service_name => 'frr_exporter',
|
|
address => $addr,
|
|
port => $port,
|
|
tags => [
|
|
'metrics',
|
|
'metrics_scheme=http',
|
|
'metrics_job=frr',
|
|
],
|
|
checks => [
|
|
{
|
|
id => 'frr_exporter_http_check',
|
|
name => 'frr_exporter HTTP Check',
|
|
http => "http://${facts['networking']['fqdn']}:${port}",
|
|
method => 'GET',
|
|
tls_skip_verify => true,
|
|
interval => '10s',
|
|
timeout => '1s',
|
|
},
|
|
],
|
|
}
|
|
}
|
|
}
|