From 82fd28e30e88c6282572f5c7a176470a414ea529 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sat, 2 Jul 2022 16:12:54 +0100 Subject: [PATCH] Make sure the correct gem is used to install ruby packages --- cookbooks/overpass/metadata.rb | 3 ++- cookbooks/overpass/recipes/default.rb | 7 +++++-- cookbooks/planet/metadata.rb | 1 + cookbooks/planet/recipes/replication.rb | 8 +++++--- cookbooks/ruby/attributes/default.rb | 1 + cookbooks/ruby/recipes/default.rb | 4 ++-- cookbooks/tile/metadata.rb | 1 + cookbooks/tile/recipes/default.rb | 16 ++++++++++++---- cookbooks/web/recipes/rails.rb | 13 ++++++++++--- 9 files changed, 39 insertions(+), 15 deletions(-) diff --git a/cookbooks/overpass/metadata.rb b/cookbooks/overpass/metadata.rb index e9755fe5d..cde954602 100644 --- a/cookbooks/overpass/metadata.rb +++ b/cookbooks/overpass/metadata.rb @@ -7,6 +7,7 @@ description "Installs and configures an Overpass server" version "1.0.0" supports "ubuntu" depends "accounts" -depends "munin" depends "apache" +depends "munin" +depends "ruby" depends "systemd" diff --git a/cookbooks/overpass/recipes/default.rb b/cookbooks/overpass/recipes/default.rb index c53153339..690a28445 100644 --- a/cookbooks/overpass/recipes/default.rb +++ b/cookbooks/overpass/recipes/default.rb @@ -18,8 +18,9 @@ # include_recipe "accounts" -include_recipe "munin" include_recipe "apache" +include_recipe "munin" +include_recipe "ruby" username = "overpass" basedir = data_bag_item("accounts", username)["home"] @@ -72,7 +73,9 @@ end ## Setup Apache -gem_package "rotp" +gem_package "rotp" do + gem_binary node[:ruby][:gem] +end directory "#{basedir}/apache" do owner "root" diff --git a/cookbooks/planet/metadata.rb b/cookbooks/planet/metadata.rb index 6bc12d40f..da36c0645 100644 --- a/cookbooks/planet/metadata.rb +++ b/cookbooks/planet/metadata.rb @@ -12,5 +12,6 @@ depends "apt" depends "git" depends "incron" depends "munin" +depends "ruby" depends "osmosis" depends "systemd" diff --git a/cookbooks/planet/recipes/replication.rb b/cookbooks/planet/recipes/replication.rb index 629186fe2..0a9387d19 100644 --- a/cookbooks/planet/recipes/replication.rb +++ b/cookbooks/planet/recipes/replication.rb @@ -22,6 +22,8 @@ require "yaml" include_recipe "accounts" include_recipe "apt" include_recipe "osmosis" +include_recipe "ruby" +include_recipe "tools" db_passwords = data_bag_item("db", "passwords") @@ -29,8 +31,6 @@ db_passwords = data_bag_item("db", "passwords") package %w[ postgresql-client - ruby - ruby-dev ruby-libxml make gcc @@ -39,7 +39,9 @@ package %w[ osmdbt ] -gem_package "pg" +gem_package "pg" do + gem_binary node[:ruby][:gem] +end ## Build preload library to flush files diff --git a/cookbooks/ruby/attributes/default.rb b/cookbooks/ruby/attributes/default.rb index 33ce58c0f..4ed2a3bb7 100644 --- a/cookbooks/ruby/attributes/default.rb +++ b/cookbooks/ruby/attributes/default.rb @@ -3,4 +3,5 @@ default[:ruby][:version] = if node[:lsb][:release].to_f < 22.04 else "3.0" end +default[:ruby][:gem] = "/usr/bin/gem#{node[:ruby][:version]}" default[:ruby][:bundle] = "/usr/bin/bundle#{node[:ruby][:version]}" diff --git a/cookbooks/ruby/recipes/default.rb b/cookbooks/ruby/recipes/default.rb index 3ec7b0329..a2833aefa 100644 --- a/cookbooks/ruby/recipes/default.rb +++ b/cookbooks/ruby/recipes/default.rb @@ -29,13 +29,13 @@ package %W[ gem_package "bundler#{ruby_version}-1" do package_name "bundler" version "~> 1.17.3" - gem_binary "gem#{ruby_version}" + gem_binary node[:ruby][:gem] options "--format-executable" end gem_package "bundler#{ruby_version}-2" do package_name "bundler" version "~> 2.3.16" - gem_binary "gem#{ruby_version}" + gem_binary node[:ruby][:gem] options "--format-executable" end diff --git a/cookbooks/tile/metadata.rb b/cookbooks/tile/metadata.rb index bd84ccec0..b07aad4f2 100644 --- a/cookbooks/tile/metadata.rb +++ b/cookbooks/tile/metadata.rb @@ -14,5 +14,6 @@ depends "nodejs" depends "postgresql" depends "prometheus" depends "python" +depends "ruby" depends "systemd" depends "tools" diff --git a/cookbooks/tile/recipes/default.rb b/cookbooks/tile/recipes/default.rb index 7f09a2777..40039b314 100644 --- a/cookbooks/tile/recipes/default.rb +++ b/cookbooks/tile/recipes/default.rb @@ -25,6 +25,7 @@ include_recipe "nodejs" include_recipe "postgresql" include_recipe "prometheus" include_recipe "python" +include_recipe "ruby" include_recipe "tools" blocks = data_bag_item("tile", "blocks") @@ -508,15 +509,22 @@ end package %w[ osm2pgsql - ruby osmium-tool pyosmium python3-pyproj ] -gem_package "apachelogregex" -gem_package "file-tail" -gem_package "lru_redux" +gem_package "apachelogregex" do + gem_binary node[:ruby][:gem] +end + +gem_package "file-tail" do + gem_binary node[:ruby][:gem] +end + +gem_package "lru_redux" do + gem_binary node[:ruby][:gem] +end remote_directory "/usr/local/bin" do source "bin" diff --git a/cookbooks/web/recipes/rails.rb b/cookbooks/web/recipes/rails.rb index 44ce2a4cd..50758caea 100644 --- a/cookbooks/web/recipes/rails.rb +++ b/cookbooks/web/recipes/rails.rb @@ -173,8 +173,13 @@ template "/usr/local/bin/cleanup-rails-assets" do mode "755" end -gem_package "apachelogregex" -gem_package "file-tail" +gem_package "apachelogregex" do + gem_binary node[:ruby][:gem] +end + +gem_package "file-tail" do + gem_binary node[:ruby][:gem] +end template "/usr/local/bin/api-statistics" do source "api-statistics.erb" @@ -204,7 +209,9 @@ service "api-statistics" do subscribes :restart, "systemd_service[api-statistics]" end -gem_package "hpricot" +gem_package "hpricot" do + gem_binary node[:ruby][:gem] +end munin_plugin "api_calls_status" munin_plugin "api_calls_num" -- 2.39.5