diff --git a/nodes/gitea-2.json b/nodes/gitea-2.json index bae39d8..0e04854 100644 --- a/nodes/gitea-2.json +++ b/nodes/gitea-2.json @@ -39,6 +39,7 @@ "timezone_iii::debian", "ntp::default", "ntp::apparmor", + "kosmos-base::journald_conf", "kosmos-base::systemd_emails", "apt::unattended-upgrades", "kosmos-base::firewall", @@ -49,6 +50,13 @@ "postfix::sasl_auth", "hostname::default", "firewall::default", + "kosmos_gitea::compile_from_source", + "git::default", + "git::package", + "kosmos-nodejs::default", + "nodejs::nodejs_from_package", + "nodejs::repo", + "golang::default", "backup::default", "logrotate::default" ], diff --git a/roles/gitea.rb b/roles/gitea.rb index 5f7fd2a..fde43d2 100644 --- a/roles/gitea.rb +++ b/roles/gitea.rb @@ -5,3 +5,11 @@ run_list %w( kosmos_gitea::default kosmos_gitea::backup ) + +override_attributes( + "gitea" => { + "repo" => "https://github.com/67P/gitea.git", + "revision" => "ldap_sync", + "log" => { "level" => "Info" } + }, +) diff --git a/site-cookbooks/kosmos_gitea/attributes/default.rb b/site-cookbooks/kosmos_gitea/attributes/default.rb index d83d71c..2adc315 100644 --- a/site-cookbooks/kosmos_gitea/attributes/default.rb +++ b/site-cookbooks/kosmos_gitea/attributes/default.rb @@ -1,13 +1,21 @@ -node.default["gitea"]["version"] = "1.23.7" -node.default["gitea"]["checksum"] = "3c0a7121ad1d9c525a92c68a7c040546553cd41e7464ce2fa811246b648c0a46" +node.default["gitea"]["version"] = "1.23.8" +node.default["gitea"]["checksum"] = "827037e7ca940866918abc62a7488736923396c467fcb4acd0dd9829bb6a6f4c" +node.default["gitea"]["repo"] = nil +node.default["gitea"]["revision"] = nil node.default["gitea"]["working_directory"] = "/var/lib/gitea" node.default["gitea"]["port"] = 3000 node.default["gitea"]["postgresql_host"] = "localhost:5432" node.default["gitea"]["domain"] = "gitea.kosmos.org" node.default["gitea"]["config"] = { + "log": { + "level" => "Info", + "logger.router.MODE" => "", + "logger.xorm.MODE" => "", + "logger.access.MODE" => "" + }, "actions": { - "enabled": true + "enabled" => true }, "webhook": { "allowed_host_list" => "external,127.0.1.1" diff --git a/site-cookbooks/kosmos_gitea/metadata.rb b/site-cookbooks/kosmos_gitea/metadata.rb index f842b03..d643f62 100644 --- a/site-cookbooks/kosmos_gitea/metadata.rb +++ b/site-cookbooks/kosmos_gitea/metadata.rb @@ -10,5 +10,8 @@ chef_version '>= 14.0' depends "firewall" depends "kosmos_openresty" depends "kosmos_postgresql" -depends "backup" depends "kosmos-dirsrv" +depends 'kosmos-nodejs' +depends 'git' +depends 'golang' +depends "backup" diff --git a/site-cookbooks/kosmos_gitea/recipes/compile_from_source.rb b/site-cookbooks/kosmos_gitea/recipes/compile_from_source.rb new file mode 100644 index 0000000..488d8cc --- /dev/null +++ b/site-cookbooks/kosmos_gitea/recipes/compile_from_source.rb @@ -0,0 +1,42 @@ +# +# Cookbook:: kosmos_gitea +# Recipe:: compile_from_source +# +# Compiles/installs Gitea from source +# + +include_recipe "git" + +node.override["nodejs"]["repo"] = "https://deb.nodesource.com/node_20.x" +include_recipe 'kosmos-nodejs' + +node.override["golang"]["version"] = "1.23.9" +include_recipe "golang" + +link "/usr/local/bin/go" do + to "/usr/local/go/bin/go" +end + +source_dir = "/opt/gitea" + +git source_dir do + repository node["gitea"]["repo"] + revision node["gitea"]["revision"] + action :sync + notifies :run, "execute[npm_install]", :immediately +end + +execute "npm_install" do + cwd source_dir + command "npm ci" + action :nothing + notifies :run, "bash[compile_gitea]", :immediately +end + +bash "compile_gitea" do + cwd source_dir + environment "TAGS" => "bindata" + code "make build" + action :nothing + notifies :restart, "service[gitea]", :delayed +end diff --git a/site-cookbooks/kosmos_gitea/recipes/default.rb b/site-cookbooks/kosmos_gitea/recipes/default.rb index afae849..ce1bc41 100644 --- a/site-cookbooks/kosmos_gitea/recipes/default.rb +++ b/site-cookbooks/kosmos_gitea/recipes/default.rb @@ -5,11 +5,12 @@ version = node["gitea"]["version"] download_url = "https://dl.gitea.io/gitea/#{version}/gitea-#{version}-linux-amd64" +compile_from_source = node["gitea"]["repo"] && node["gitea"]["revision"] working_directory = node["gitea"]["working_directory"] git_home_directory = "/home/git" repository_root_directory = "#{git_home_directory}/gitea-repositories" config_directory = "/etc/gitea" -gitea_binary_path = "/usr/local/bin/gitea" +gitea_binary_path = compile_from_source ? "/opt/gitea/gitea" : "/usr/local/bin/gitea" gitea_data_bag_item = data_bag_item("credentials", "gitea") smtp_credentials = data_bag_item("credentials", "smtp") smtp_addr = smtp_credentials["relayhost"].split(":")[0] @@ -18,7 +19,6 @@ jwt_secret = gitea_data_bag_item["jwt_secret"] internal_token = gitea_data_bag_item["internal_token"] secret_key = gitea_data_bag_item["secret_key"] -# Dependency package "git" user "git" do @@ -108,11 +108,15 @@ template "#{config_directory}/app.ini" do notifies :restart, "service[gitea]", :delayed end -remote_file gitea_binary_path do - source download_url - checksum node['gitea']['checksum'] - mode "0755" - notifies :restart, "service[gitea]", :delayed +if compile_from_source + include_recipe "kosmos_gitea::compile_from_source" +else + remote_file gitea_binary_path do + source download_url + checksum node['gitea']['checksum'] + mode "0755" + notifies :restart, "service[gitea]", :delayed + end end execute "systemctl daemon-reload" do diff --git a/site-cookbooks/kosmos_gitea/templates/default/app.ini.erb b/site-cookbooks/kosmos_gitea/templates/default/app.ini.erb index 0a846fa..0e819d0 100644 --- a/site-cookbooks/kosmos_gitea/templates/default/app.ini.erb +++ b/site-cookbooks/kosmos_gitea/templates/default/app.ini.erb @@ -74,8 +74,11 @@ ENABLE_OPENID_SIGNIN = false ENABLE_OPENID_SIGNUP = false [log] -MODE = console -LEVEL = Debug +MODE = console +LEVEL = <%= @config["log"]["level"] %> +logger.router.MODE = <%= @config["log"]["logger.router.MODE"] %> +logger.xorm.MODE = <%= @config["log"]["logger.xorm.MODE"] %> +logger.access.MODE = <%= @config["log"]["logger.access.MODE"] %> [attachment] ENABLED = true