From f7009e49bf86b7b70827cbb97a17b067f5e06588 Mon Sep 17 00:00:00 2001 From: Grant Slater Date: Mon, 9 Mar 2026 14:02:49 +0000 Subject: [PATCH] Add initial cookbook for installing fastli cli tool --- .github/workflows/test-kitchen.yml | 1 + .kitchen.yml | 3 ++ cookbooks/fastly/metadata.rb | 8 ++++ cookbooks/fastly/recipes/default.rb | 45 ++++++++++++++++++++++ roles/nominatim.rb | 3 +- roles/tile.rb | 3 +- roles/web-frontend.rb | 3 +- test/integration/fastly/inspec/cli_spec.rb | 7 ++++ 8 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 cookbooks/fastly/metadata.rb create mode 100644 cookbooks/fastly/recipes/default.rb create mode 100644 test/integration/fastly/inspec/cli_spec.rb diff --git a/.github/workflows/test-kitchen.yml b/.github/workflows/test-kitchen.yml index 928c01e8c..1d6c52fc5 100644 --- a/.github/workflows/test-kitchen.yml +++ b/.github/workflows/test-kitchen.yml @@ -44,6 +44,7 @@ jobs: - elasticsearch - exim - fail2ban + - fastly - foundation-birthday - foundation-board - foundation-dwg diff --git a/.kitchen.yml b/.kitchen.yml index d45cc0a95..1a3cc71d6 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -206,6 +206,9 @@ suites: - name: fail2ban run_list: - recipe[fail2ban::default] + - name: fastly + run_list: + - recipe[fastly::default] - name: foundation-birthday run_list: - recipe[foundation::birthday] diff --git a/cookbooks/fastly/metadata.rb b/cookbooks/fastly/metadata.rb new file mode 100644 index 000000000..067c107f3 --- /dev/null +++ b/cookbooks/fastly/metadata.rb @@ -0,0 +1,8 @@ +name "fastly" +maintainer "OpenStreetMap Administrators" +maintainer_email "admins@openstreetmap.org" +license "Apache-2.0" +description "Install Fastly management tools" + +version "1.0.0" +supports "ubuntu" diff --git a/cookbooks/fastly/recipes/default.rb b/cookbooks/fastly/recipes/default.rb new file mode 100644 index 000000000..97fa216e2 --- /dev/null +++ b/cookbooks/fastly/recipes/default.rb @@ -0,0 +1,45 @@ +# +# Cookbook:: fastly +# Recipe:: default +# +# Copyright:: 2026, OpenStreetMap Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package %w[ + jq +] + +cache_dir = Chef::Config[:file_cache_path] + +fastly_version = "14.0.4" + +fastly_arch = if arm? + "arm64" + else + "amd64" + end + +remote_file "#{cache_dir}/fastly-#{fastly_version}.deb" do + source "https://github.com/fastly/cli/releases/download/v#{fastly_version}/fastly_#{fastly_version}_linux_#{fastly_arch}.deb" + owner "root" + group "root" + mode "644" + backup false +end + +dpkg_package "fastly" do + source "#{cache_dir}/fastly-#{fastly_version}.deb" + version fastly_version +end diff --git a/roles/nominatim.rb b/roles/nominatim.rb index 20f5af62d..31034bbfc 100644 --- a/roles/nominatim.rb +++ b/roles/nominatim.rb @@ -70,5 +70,6 @@ default_attributes( ) run_list( - "recipe[nominatim::default]" + "recipe[nominatim::default]", + "recipe[fastly]" ) diff --git a/roles/tile.rb b/roles/tile.rb index e08e4ec85..c5208a642 100644 --- a/roles/tile.rb +++ b/roles/tile.rb @@ -113,5 +113,6 @@ default_attributes( ) run_list( - "recipe[tile]" + "recipe[tile]", + "recipe[fastly]" ) diff --git a/roles/web-frontend.rb b/roles/web-frontend.rb index e7c0e5850..f2e5cb72b 100644 --- a/roles/web-frontend.rb +++ b/roles/web-frontend.rb @@ -53,5 +53,6 @@ default_attributes( run_list( "role[web]", - "recipe[web::frontend]" + "recipe[web::frontend]", + "recipe[fastly]" ) diff --git a/test/integration/fastly/inspec/cli_spec.rb b/test/integration/fastly/inspec/cli_spec.rb new file mode 100644 index 000000000..877d7fb60 --- /dev/null +++ b/test/integration/fastly/inspec/cli_spec.rb @@ -0,0 +1,7 @@ +describe package("fastly") do + it { should be_installed } +end + +describe command("fastly version") do + its(:exit_status) { should eq 0 } +end -- 2.47.3