3
0

OP#189 add the services

This commit is contained in:
2025-12-04 14:16:06 +01:00
parent dcbad998f4
commit 639d4b0099
7 changed files with 91 additions and 4 deletions

View File

@@ -6,6 +6,7 @@
"GOMAXPROCS", "GOMAXPROCS",
"Iseconds", "Iseconds",
"nullglob", "nullglob",
"oneshot",
"PGDATABASE", "PGDATABASE",
"PGHOST", "PGHOST",
"PGPASSWORD", "PGPASSWORD",
@@ -13,7 +14,9 @@
"PGUSER", "PGUSER",
"pipefail", "pipefail",
"procs", "procs",
"prun",
"readaccess", "readaccess",
"refreshonly",
"reqpackage", "reqpackage",
"rpms", "rpms",
"shopt", "shopt",

View File

@@ -6,4 +6,10 @@
class prometheus_cd::main::config ( class prometheus_cd::main::config (
) inherits prometheus_cd::params { ) inherits prometheus_cd::params {
include prometheus_cd::main::service include prometheus_cd::main::service
exec { 'systemd-daemon-reload':
command => '/bin/systemctl daemon-reload',
path => ['/bin', '/usr/bin'],
refreshonly => true,
}
} }

View File

@@ -66,18 +66,44 @@ class prometheus_cd::main::files (
seltype => usr_, seltype => usr_,
seluser => unconfined_u, seluser => unconfined_u,
content => template('prometheus_cd/prune.env.erb'), content => template('prometheus_cd/prune.env.erb'),
# notify Service ToDo, }
file { $ps_pruning_svc_file:
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
selrange => s0,
selrole => object_r,
seltype => systemd_unit_file_t,
seluser => unconfined_u,
content => template('prometheus_cd/prometheus-prune-service.erb'),
notify => Exec['systemd-daemon-reload'],
}
file { $ps_pruning_timer_file:
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
selrange => s0,
selrole => object_r,
seltype => systemd_unit_file_t,
seluser => unconfined_u,
content => template('prometheus_cd/prometheus-prune-timer.erb'),
notify => Exec['systemd-daemon-reload'],
} }
} }
if $ps_enable_pruning == false { if $ps_enable_pruning == false {
file { $ps_pruning_file: file { $ps_pruning_file:
ensure => absent, ensure => absent,
# notify Service ToDo, notify => Exec['systemd-daemon-reload'],
} }
file { $ps_env_file: file { $ps_env_file:
ensure => absent, ensure => absent,
# notify Service ToDo, }
file { $ps_pruning_svc_file:
ensure => absent,
notify => Exec['systemd-daemon-reload'],
} }
} }
} }

View File

@@ -23,4 +23,28 @@ class prometheus_cd::main::service (
enable => true, enable => true,
} }
} }
if $ps_enable_pruning == true {
service { $ps_prune_service:
ensure => running,
hasstatus => true,
hasrestart => true,
enable => true,
}
service { $ps_prune_timer:
ensure => running,
hasstatus => true,
hasrestart => true,
enable => true,
}
}
if $ps_enable_pruning == false {
service { $ps_prune_service:
ensure => stopped,
enable => true,
}
service { $ps_prune_timer:
ensure => stopped,
enable => true,
}
}
} }

View File

@@ -109,15 +109,20 @@ class prometheus_cd::params (
# dirs # dirs
$ps_main_dir = '/etc/prometheus' $ps_main_dir = '/etc/prometheus'
$ps_system_file_dir = '/etc/systemd/system/prometheus.service.d' $ps_system_file_dir = '/etc/systemd/system/prometheus.service.d'
$ps_system_dir = '/etc/systemd/system/'
# files # files
$ps_main_file = "${ps_main_dir}/prometheus.yml" $ps_main_file = "${ps_main_dir}/prometheus.yml"
$ps_web_config_file = "${ps_main_dir}/web.yml" $ps_web_config_file = "${ps_main_dir}/web.yml"
$ps_system_service_file = "${ps_system_file_dir}/override.conf" $ps_system_service_file = "${ps_system_file_dir}/override.conf"
$ps_pruning_svc_file = "${ps_system_dir}/prometheus-prune.service"
$ps_pruning_timer_file = "${ps_system_dir}/prometheus-prune.timer"
# services # services
$ps_prom_service = 'prometheus' $ps_prom_service = 'prometheus'
$ps_ne_service = 'node_exporter' $ps_ne_service = 'node_exporter'
$ps_prune_service = 'prometheus-prune.service'
$ps_prune_timer = 'prometheus-prune.timer'
# includes must be last # includes must be last
include prometheus_cd::main::config include prometheus_cd::main::config

View File

@@ -0,0 +1,10 @@
[Unit]
Description=Run Prometheus TSDB prune script every 6 hours
[Timer]
OnBootSec=10min
OnUnitActiveSec=6h
Persistent=true
[Install]
WantedBy=timers.target

View File

@@ -0,0 +1,13 @@
[Unit]
Description=Prometheus TSDB prune service
Wants=network-online.target
After=network-online.target
[Service]
Type=oneshot
User=prometheus
Group=prometheus
EnvironmentFile=<%= @ps_env_file %>
ExecStart=<%= @ps_pruning_file %>
Nice=10
IOWeight=80