From 60633da5800bca4e65cdfb3dc6c5c88a36ecf40f Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sat, 5 Sep 2026 12:34:11 +0100 Subject: [PATCH] Add a glitchtip cookbook --- .github/workflows/test-kitchen.yml | 1 + .kitchen.yml | 3 + cookbooks/glitchtip/attributes/default.rb | 6 ++ cookbooks/glitchtip/metadata.rb | 11 +++ cookbooks/glitchtip/recipes/default.rb | 69 +++++++++++++++++++ test/data_bags/glitchtip/passwords.json | 5 ++ .../glitchtip/inspec/podman_spec.rb | 17 +++++ .../glitchtip/inspec/postgresql_spec.rb | 13 ++++ .../glitchtip/inspec/valkey_spec.rb | 13 ++++ 9 files changed, 138 insertions(+) create mode 100644 cookbooks/glitchtip/attributes/default.rb create mode 100644 cookbooks/glitchtip/metadata.rb create mode 100644 cookbooks/glitchtip/recipes/default.rb create mode 100644 test/data_bags/glitchtip/passwords.json create mode 100644 test/integration/glitchtip/inspec/podman_spec.rb create mode 100644 test/integration/glitchtip/inspec/postgresql_spec.rb create mode 100644 test/integration/glitchtip/inspec/valkey_spec.rb diff --git a/.github/workflows/test-kitchen.yml b/.github/workflows/test-kitchen.yml index bede35124..eeb25fb8c 100644 --- a/.github/workflows/test-kitchen.yml +++ b/.github/workflows/test-kitchen.yml @@ -59,6 +59,7 @@ jobs: - git - git-server - git-web + - glitchtip - gps-tile - hardware - hot diff --git a/.kitchen.yml b/.kitchen.yml index a06533515..44f6a30d4 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -238,6 +238,9 @@ suites: - name: git-web run_list: - recipe[git::web] + - name: glitchtip + run_list: + - recipe[glitchtip::default] - name: gps-tile run_list: - recipe[gps-tile::default] diff --git a/cookbooks/glitchtip/attributes/default.rb b/cookbooks/glitchtip/attributes/default.rb new file mode 100644 index 000000000..38771f430 --- /dev/null +++ b/cookbooks/glitchtip/attributes/default.rb @@ -0,0 +1,6 @@ +default[:glitchtip][:database_cluster] = "18/main" +default[:glitchtip][:database_name] = "glitchtip" +default[:glitchtip][:database_user] = "glitchtip" +default[:glitchtip][:database_password] = "database" + +default[:postgresql][:versions] |= %w[18] diff --git a/cookbooks/glitchtip/metadata.rb b/cookbooks/glitchtip/metadata.rb new file mode 100644 index 000000000..792ace6d9 --- /dev/null +++ b/cookbooks/glitchtip/metadata.rb @@ -0,0 +1,11 @@ +name "glitchtip" +maintainer "OpenStreetMap Administrators" +maintainer_email "admins@openstreetmap.org" +license "Apache-2.0" +description "Installs and configures GlitchTip" + +version "1.0.0" +supports "ubuntu" +depends "podman" +depends "postgresql" +depends "valkey" diff --git a/cookbooks/glitchtip/recipes/default.rb b/cookbooks/glitchtip/recipes/default.rb new file mode 100644 index 000000000..ea56325f8 --- /dev/null +++ b/cookbooks/glitchtip/recipes/default.rb @@ -0,0 +1,69 @@ +# +# Cookbook:: glitchtip +# 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. +# + +include_recipe "podman" +include_recipe "postgresql" +include_recipe "valkey" + +passwords = data_bag_item("glitchtip", "passwords") + +database_cluster = node[:glitchtip][:database_cluster] +database_name = node[:glitchtip][:database_name] +database_user = node[:glitchtip][:database_user] +database_password = passwords[node[:glitchtip][:database_password]] + +postgresql_user database_user do + cluster database_cluster + password database_password +end + +postgresql_database database_name do + cluster database_cluster + owner database_user +end + +directory "/srv/glitchtip.openstreetmap.org/uploads" do + owner "root" + group "root" + mode "0755" + recursive true +end + +database_url = "postgres://#{database_user}:#{database_password}@host.containers.internal:5432/#{database_name}" + +podman_site "glitchtip.openstreetmap.org" do + image "docker.io/glitchtip/glitchtip:6" + port 8000 + aliases ["glitchtip.osm.org"] + environment "DATABASE_URL" => database_url, + "VALKEY_URL" => "redis://host.containers.internal:6379", + "SECRET_KEY" => passwords["secret"], + "EMAIL_URL" => "smtp://host.containers.internal:25", + "DEFAULT_FROM_MAIL" => "admins@openstreetmap.org", + "ALLOWED_HOSTS" => "glitchtip.openstreetmap.org,glitchtip.osm.org", + "ENABLE_ADMIN" => "False", + "ENABLE_OBSERVABILITY_API" => "True", + "ENABLE_OPENAPI" => "False", + "GLITCHTIP_DOMAIN" => "https://glitchtip.openstreetmap.org", + "GLITCHTIP_ENABLE_DUCKDB" => "False", + "GLITCHTIP_ENABLE_MCP" => "False", + "GLITCHTIP_INSTANCE_NAME" => "OpenStreetMap\\'s GlitchTip", + "SERVER_ROLE" => "all_in_one" + volumes "/srv/glitchtip.openstreetmap.org/uploads" => "/code/uploads" +end diff --git a/test/data_bags/glitchtip/passwords.json b/test/data_bags/glitchtip/passwords.json new file mode 100644 index 000000000..a6db9a550 --- /dev/null +++ b/test/data_bags/glitchtip/passwords.json @@ -0,0 +1,5 @@ +{ + "id": "passwords", + "database": "database-password", + "secret": "glitchtip-secret" +} diff --git a/test/integration/glitchtip/inspec/podman_spec.rb b/test/integration/glitchtip/inspec/podman_spec.rb new file mode 100644 index 000000000..7be32f745 --- /dev/null +++ b/test/integration/glitchtip/inspec/podman_spec.rb @@ -0,0 +1,17 @@ +describe package("podman") do + it { should be_installed } +end + +describe service("podman-auto-update.timer") do + it { should be_enabled } + it { should be_running } +end + +describe service("podman-system-prune.timer") do + it { should be_enabled } + it { should be_running } +end + +describe command("podman image inspect glitchtip/glitchtip:6") do + its("exit_status") { should eq 0 } +end diff --git a/test/integration/glitchtip/inspec/postgresql_spec.rb b/test/integration/glitchtip/inspec/postgresql_spec.rb new file mode 100644 index 000000000..e068398aa --- /dev/null +++ b/test/integration/glitchtip/inspec/postgresql_spec.rb @@ -0,0 +1,13 @@ +describe package("postgresql-18") do + it { should be_installed } +end + +describe service("postgresql@18-main") do + it { should be_enabled } + it { should be_running } +end + +describe port(5432) do + it { should be_listening } + its("protocols") { should cmp %w[tcp tcp6] } +end diff --git a/test/integration/glitchtip/inspec/valkey_spec.rb b/test/integration/glitchtip/inspec/valkey_spec.rb new file mode 100644 index 000000000..6067f116f --- /dev/null +++ b/test/integration/glitchtip/inspec/valkey_spec.rb @@ -0,0 +1,13 @@ +describe package("valkey-server") do + it { should be_installed } +end + +describe service("valkey") do + it { should be_enabled } + it { should be_running } +end + +describe port(6379) do + it { should be_listening } + its("protocols") { should cmp %w[tcp tcp6] } +end -- 2.47.3