From b983fa89793a0c110f70ae42e8187ca3024fc434 Mon Sep 17 00:00:00 2001 From: Grant Slater Date: Mon, 18 Aug 2025 18:38:27 +0100 Subject: [PATCH] Use prometheus-exporters github releases instead of slow git clone --- cookbooks/prometheus/metadata.rb | 1 - cookbooks/prometheus/recipes/default.rb | 28 +++++++++++++++------- cookbooks/prometheus/resources/exporter.rb | 2 +- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/cookbooks/prometheus/metadata.rb b/cookbooks/prometheus/metadata.rb index 6148979b9..e3f4dc4d5 100644 --- a/cookbooks/prometheus/metadata.rb +++ b/cookbooks/prometheus/metadata.rb @@ -9,6 +9,5 @@ supports "ubuntu" depends "apache" depends "apt" depends "awscli" -depends "git" depends "hardware" depends "networking" diff --git a/cookbooks/prometheus/recipes/default.rb b/cookbooks/prometheus/recipes/default.rb index df3ec2ea5..98897e799 100644 --- a/cookbooks/prometheus/recipes/default.rb +++ b/cookbooks/prometheus/recipes/default.rb @@ -17,10 +17,12 @@ # limitations under the License. # -include_recipe "git" include_recipe "networking" -package "ruby" +package %w[ + ruby + zstd +] if node.internal_ipaddress node.default[:prometheus][:mode] = "internal" @@ -46,13 +48,23 @@ directory "/opt/prometheus" do recursive true end -git "/opt/prometheus-exporters" do - action :sync - repository "https://github.com/openstreetmap/prometheus-exporters.git" - revision "main" - depth 1 - user "root" +cache_dir = Chef::Config[:file_cache_path] + +remote_file "#{cache_dir}/prometheus-exporters.tar.zst" do + source "https://github.com/openstreetmap/prometheus-exporters/releases/latest/download/prometheus-exporters-#{node[:kernel][:machine]}-only.tar.zst" + owner "root" group "root" + mode "644" + backup false + ignore_failure true +end + +archive_file "/opt/prometheus-exporters" do + path "#{cache_dir}/prometheus-exporters.tar.zst" + destination "/opt/prometheus-exporters" + overwrite true + action :nothing + subscribes :extract, "remote_file[#{cache_dir}/prometheus-exporters.tar.zst]", :immediately end directory "/etc/prometheus/collectors" do diff --git a/cookbooks/prometheus/resources/exporter.rb b/cookbooks/prometheus/resources/exporter.rb index 5075c5d6a..d47b64751 100644 --- a/cookbooks/prometheus/resources/exporter.rb +++ b/cookbooks/prometheus/resources/exporter.rb @@ -193,5 +193,5 @@ action_class do end def after_created - subscribes :restart, "git[/opt/prometheus-exporters]" + subscribes :restart, "archive_file[/opt/prometheus-exporters]" end -- 2.39.5