diff --git a/nodes b/nodes index af52918..528c84f 160000 --- a/nodes +++ b/nodes @@ -1 +1 @@ -Subproject commit af52918423133f84f0858c02d9f8f6726a08fd48 +Subproject commit 528c84f98f800cc44d44d23dce7dce5dc919fb2e diff --git a/site-cookbooks/kosmos_gitea/CHANGELOG.md b/site-cookbooks/kosmos_gitea/CHANGELOG.md index 9f0ab30..c0f750b 100644 --- a/site-cookbooks/kosmos_gitea/CHANGELOG.md +++ b/site-cookbooks/kosmos_gitea/CHANGELOG.md @@ -2,6 +2,20 @@ This file is used to list changes made in each version of the kosmos_gitea cookbook. +# 0.2.2 + +- Add `config.yaml` for the gitea actions runner, enabling the built-in cache + server (listening on the Docker bridge gateway `172.17.0.1`) and bumping + `runner.capacity` to 2 for concurrent job execution. Each runner gets a unique + cache port derived from `cache_base_port` (8088) + its index in the runners + data bag. +- Set `container.network` to a user-defined Docker bridge network + (`gitea-actions`, subnet `172.20.0.0/16`) so job containers get DNS resolution + for service containers (e.g. `redis`) while keeping the cache server reachable + at the network gateway `172.20.0.1`. +- Open the cache port in the firewall for Docker bridge traffic + (`172.20.0.0/16`), fixing `Request timeout` errors from `actions/cache`. + # 0.1.0 Initial release. diff --git a/site-cookbooks/kosmos_gitea/attributes/default.rb b/site-cookbooks/kosmos_gitea/attributes/default.rb index 7108259..262c8d1 100644 --- a/site-cookbooks/kosmos_gitea/attributes/default.rb +++ b/site-cookbooks/kosmos_gitea/attributes/default.rb @@ -25,3 +25,17 @@ node.default["gitea"]["config"] = { node.default["gitea"]["runner"]["version"] = "2.0.0" node.default["gitea"]["runner"]["checksum"] = "447156b33407ee045409f5552bd4a188a315cdd4085b4b498d8d4a9ad26c9f73" +node.default["gitea"]["runner"]["cache_base_port"] = 8088 +node.default["gitea"]["runner"]["config"] = { + "runner" => { + "capacity" => 2 + }, + "container" => { + "network" => "gitea-actions" # User-defined bridge network: provides DNS for service containers + }, + "cache" => { + "enabled" => true, + "host" => "172.20.0.1" # Gateway of the gitea-actions network, reachable from job containers + # Port is set per-runner (cache_base_port + index) in the runner recipe + } +} diff --git a/site-cookbooks/kosmos_gitea/metadata.rb b/site-cookbooks/kosmos_gitea/metadata.rb index bd9bc2f..820c55a 100644 --- a/site-cookbooks/kosmos_gitea/metadata.rb +++ b/site-cookbooks/kosmos_gitea/metadata.rb @@ -4,7 +4,7 @@ maintainer_email 'ops@kosmos.org' license 'MIT' description 'Installs/configures Gitea' long_description 'Installs/configures Gitea' -version '0.2.1' +version '0.2.2' chef_version '>= 14.0' depends "firewall" diff --git a/site-cookbooks/kosmos_gitea/recipes/runner.rb b/site-cookbooks/kosmos_gitea/recipes/runner.rb index c864356..bd63009 100644 --- a/site-cookbooks/kosmos_gitea/recipes/runner.rb +++ b/site-cookbooks/kosmos_gitea/recipes/runner.rb @@ -35,14 +35,39 @@ directory "#{working_directory}/runners" do mode "0700" end -runners.each do |runner| +execute "create_gitea_actions_network" do + command "docker network create --subnet 172.20.0.0/16 gitea-actions" + not_if "docker network inspect gitea-actions" +end + +runners.each_with_index do |runner, index| runner_name = "gitea-runner-#{runner["org"]}" runner_dir = "#{working_directory}/runners/#{runner["org"]}" + cache_port = node["gitea"]["runner"]["cache_base_port"] + index directory runner_dir do mode "0700" end + runner_config = node["gitea"]["runner"]["config"].to_hash + runner_config["cache"] = runner_config["cache"].merge("port" => cache_port) + + firewall_rule "runner_cache_#{runner["org"]}" do + command :allow + port cache_port + protocol :tcp + source "172.20.0.0/16" + end + + template "#{runner_dir}/config.yaml" do + source "runner.config.yaml.erb" + mode "0640" + owner "root" + group "root" + variables(config: runner_config) + notifies :restart, "service[#{runner_name}]", :delayed + end + bash "register_#{runner["org"]}_runner" do cwd runner_dir code <<-EOF @@ -67,7 +92,7 @@ gitea_runner register \ Type: "simple", WorkingDirectory: runner_dir, Environment: "HOME=/root", - ExecStart: "/usr/local/bin/gitea_runner daemon", + ExecStart: "/usr/local/bin/gitea_runner daemon --config #{runner_dir}/config.yaml", ExecStartPre: "/bin/sleep 3", # Wait for Gitea's API to be up when restarting at the same time Restart: "always", }, diff --git a/site-cookbooks/kosmos_gitea/templates/default/runner.config.yaml.erb b/site-cookbooks/kosmos_gitea/templates/default/runner.config.yaml.erb new file mode 100644 index 0000000..1326fb6 --- /dev/null +++ b/site-cookbooks/kosmos_gitea/templates/default/runner.config.yaml.erb @@ -0,0 +1 @@ +<%= @config.to_yaml.sub(/^---\n/, '') %>