Skip to content

Commit

Permalink
Sparse checkout the prometheus-exporters repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Firefishy committed Apr 25, 2024
1 parent 9694d64 commit 83ee81d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cookbooks/prometheus/recipes/default.rb
Expand Up @@ -46,6 +46,13 @@
recursive true
end

execute "git-sparse-clone-prometheus-exporters" do
command "git clone --depth 1 --filter=blob:none --sparse https://github.com/openstreetmap/prometheus-exporters.git /opt/prometheus-exporters"
user "root"
group "root"
not_if { (platform?("ubuntu") && node[:lsb][:release].to_f < 22.04) || ::File.exist?("/opt/prometheus-exporters") }
end

git "/opt/prometheus-exporters" do
action :sync
repository "https://github.com/openstreetmap/prometheus-exporters.git"
Expand Down
8 changes: 8 additions & 0 deletions cookbooks/prometheus/resources/collector.rb
Expand Up @@ -35,6 +35,14 @@
property :protect_kernel_modules, [true, false]

action :create do
execute "git-sparse-checkout-#{new_resource.collector}-collectors" do
command "git sparse-checkout add collectors/#{new_resource.collector}"
cwd "/opt/prometheus-exporters"
user "root"
group "root"
not_if { (platform?("ubuntu") && node[:lsb][:release].to_f < 22.04) || ::File.exist?("/opt/prometheus-exporters/collectors/#{new_resource.collector}") }
end

systemd_service service_name do
description "Prometheus #{new_resource.collector} collector"
type "oneshot"
Expand Down
8 changes: 8 additions & 0 deletions cookbooks/prometheus/resources/exporter.rb
Expand Up @@ -68,6 +68,14 @@
end
end

execute "git-sparse-checkout-#{new_resource.exporter}-exporters" do
command "git sparse-checkout add exporters/#{new_resource.exporter}"
cwd "/opt/prometheus-exporters"
user "root"
group "root"
not_if { (platform?("ubuntu") && node[:lsb][:release].to_f < 22.04) || ::File.exist?("/opt/prometheus-exporters/exporters/#{new_resource.exporter}") }
end

systemd_service service_name do
after "network-online.target"
wants "network-online.target"
Expand Down

0 comments on commit 83ee81d

Please sign in to comment.