2023-02-12 10:03:04 +01:00
|
|
|
# Class Prometheus
|
|
|
|
class prometheus (
|
|
|
|
$system_user = 'prometheus',
|
|
|
|
$container_name = 'prometheeus',
|
|
|
|
$container_image_name = 'prom/prometheus',
|
|
|
|
$container_image_version = 'latest',
|
|
|
|
$container_mount_data_folder = true,
|
2023-02-12 10:29:54 +01:00
|
|
|
$container_data_folder = '/var/lib/prometheus/metrics2',
|
2023-02-12 10:03:04 +01:00
|
|
|
$container_config_folder = '/etc/prometheus',
|
|
|
|
$container_volume_name = 'prometheus-storage',
|
|
|
|
$container_port = '9090',
|
|
|
|
$configuration = {}, # Refer to https://prometheus.io/docs/prometheus/latest/configuration/configuration/
|
|
|
|
) {
|
|
|
|
$env = [
|
|
|
|
]
|
|
|
|
if (!$container_mount_data_folder) {
|
|
|
|
podman::volume { $container_volume_name: }
|
|
|
|
$flags = {
|
|
|
|
publish => [
|
|
|
|
"${container_port}:9090",
|
|
|
|
],
|
2023-02-17 12:23:13 +01:00
|
|
|
network => 'host',
|
2023-02-12 10:03:04 +01:00
|
|
|
sysctl => 'net.ipv6.conf.all.disable_ipv6=1',
|
|
|
|
volume => [
|
2023-02-12 10:29:54 +01:00
|
|
|
"${container_volume_name}:/prometheus",
|
2023-02-12 10:03:04 +01:00
|
|
|
],
|
|
|
|
env => $env,
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
user { $system_user:
|
|
|
|
}
|
|
|
|
file { $container_data_folder:
|
|
|
|
ensure => directory,
|
|
|
|
owner => $system_user,
|
|
|
|
}
|
|
|
|
file { $container_config_folder:
|
|
|
|
ensure => directory,
|
|
|
|
owner => $system_user,
|
|
|
|
}
|
|
|
|
$flags = {
|
|
|
|
publish => [
|
|
|
|
"${container_port}:9090",
|
|
|
|
],
|
|
|
|
sysctl => 'net.ipv6.conf.all.disable_ipv6=1',
|
2023-02-17 12:23:13 +01:00
|
|
|
network => 'host',
|
2023-02-12 10:03:04 +01:00
|
|
|
volume => [
|
2023-02-12 10:29:54 +01:00
|
|
|
"${container_data_folder}:/prometheus",
|
2023-02-12 10:03:04 +01:00
|
|
|
"${container_config_folder}:/etc/prometheus",
|
|
|
|
],
|
|
|
|
env => $env,
|
|
|
|
}
|
|
|
|
file { "${container_config_folder}/prometheus.yml":
|
|
|
|
content => template('prometheus/prometheus.yml.erb'),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
podman::container { $container_name:
|
|
|
|
image => $container_image_name,
|
|
|
|
flags => $flags,
|
|
|
|
service_flags => {
|
|
|
|
timeout => '180',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|