- upgrade node_exporter, bring managed under exporters module - upgrade postgres_exporter, bring managed under exporters module - add flag to cleanup previous iterations of exporters from prometheus module - fix issues with vmclusster: replication + dedup
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
class exporters::node_exporter (
|
||||
Boolean $enable = false,
|
||||
String $user = 'node_exporter',
|
||||
String $group = 'node_exporter',
|
||||
Boolean $manage_user = true,
|
||||
Boolean $manage_service = true,
|
||||
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 => $facts['networking']['ip'],
|
||||
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',
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
class exporters::postgres_exporter (
|
||||
String $db_pass,
|
||||
String $db_user = 'postgres_exporter',
|
||||
Stdlib::Host $db_host = $facts['networking']['ip'],
|
||||
Stdlib::Port $db_port = 5432,
|
||||
Boolean $enable = false,
|
||||
String $user = 'postgres_exporter',
|
||||
String $group = 'postgres_exporter',
|
||||
Boolean $manage_user = true,
|
||||
Boolean $manage_service = true,
|
||||
Stdlib::Port $port = 9187,
|
||||
Stdlib::Absolutepath $exec_path = '/usr/bin/postgres_exporter',
|
||||
Stdlib::Absolutepath $vars_path = '/etc/sysconfig/postgres_exporter',
|
||||
Boolean $cleanup_old_postgres_exporter = false,
|
||||
){
|
||||
|
||||
if $cleanup_old_postgres_exporter {
|
||||
# remove the symlink
|
||||
file {'/usr/local/bin/postgres_exporter':
|
||||
ensure => absent
|
||||
}
|
||||
# remove the /opt/postgres_exporter-0.5.1.linux-amd64 directory
|
||||
file {'/opt/postgres_exporter-0.5.1.linux-amd64':
|
||||
ensure => absent,
|
||||
recurse => true,
|
||||
force => true,
|
||||
}
|
||||
}
|
||||
|
||||
if $enable {
|
||||
|
||||
# install required package
|
||||
package {'postgres_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 environment file
|
||||
file { $vars_path:
|
||||
ensure => file,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
content => template('exporters/postgres_exporter_sysconfig.erb')
|
||||
}
|
||||
|
||||
# manage the systemd service
|
||||
if $manage_service {
|
||||
|
||||
# Use these in notifications or file resources
|
||||
systemd::unit_file { 'postgres_exporter.service':
|
||||
content => template('exporters/postgres_exporter.service.erb'),
|
||||
enable => true,
|
||||
active => true,
|
||||
subscribe => Package['postgres_exporter'],
|
||||
}
|
||||
}
|
||||
|
||||
# manage consul service
|
||||
consul::service { 'postgres_exporter':
|
||||
service_name => 'postgres_exporter',
|
||||
address => $facts['networking']['ip'],
|
||||
port => $port,
|
||||
tags => [
|
||||
'metrics',
|
||||
'metrics_scheme=http',
|
||||
'metrics_job=postgres',
|
||||
],
|
||||
checks => [
|
||||
{
|
||||
id => 'postgres_exporter_http_check',
|
||||
name => 'postgres_exporter HTTP Check',
|
||||
http => "http://${facts['networking']['fqdn']}:${port}",
|
||||
method => 'GET',
|
||||
tls_skip_verify => true,
|
||||
interval => '10s',
|
||||
timeout => '1s',
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=Prometheus node_exporter
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
User=<%= @user %>
|
||||
Group=<%= @group %>
|
||||
ExecStart=<%= @exec_path %>
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
KillMode=process
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,16 @@
|
||||
[Unit]
|
||||
Description=Prometheus postgres_exporter
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
User=<%= @user %>
|
||||
Group=<%= @group %>
|
||||
EnvironmentFile=<%= @vars_file %>
|
||||
ExecStart=<%= @exec_path %>
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
KillMode=process
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,4 @@
|
||||
# THIS FILE IS MANAGED BY PUPPET
|
||||
DATA_SOURCE_URI="<%= @db_host %>:<%= @db_port %>/postgres?sslmode=disable"
|
||||
DATA_SOURCE_USER="<%= @db_user %>"
|
||||
DATA_SOURCE_PASS="<%= @db_pass %>"
|
||||
Reference in New Issue
Block a user