Add community prometheus cookbook

This commit is contained in:
Greg Karekinian
2026-07-03 16:35:26 +02:00
parent ec73dd5b57
commit 4cd6c41254
29 changed files with 1430 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
# frozen_string_literal: true
provides :prometheus_config
unified_mode true
use '_partial/_common'
use '_partial/_prometheus'
property :template_cookbook, String, default: 'prometheus'
property :template_source, String, default: 'prometheus.yml.erb'
property :rule_filenames, [Array, nil], default: nil
property :global_config, Hash, default: {
'scrape_interval' => '60s',
'evaluation_interval' => '60s',
}
property :allow_external_config, [true, false], default: false
default_action :create
action :create do
config_resource = new_resource
with_run_context :root do
template config_resource.config_file do
cookbook config_resource.template_cookbook
source config_resource.template_source
mode '0644'
owner config_resource.user
group config_resource.group
variables(
global_config: config_resource.global_config,
jobs: {},
rule_filenames: config_resource.rule_filenames
)
not_if { config_resource.allow_external_config }
end
end
end
action :delete do
file new_resource.config_file do
action :delete
end
end