Merge origin/master into chore/upgrade_mastodon
# Conflicts: # site-cookbooks/kosmos-mastodon/attributes/default.rb
This commit is contained in:
115 files changed
+2185
-805
No files matched your search
@@ -8,11 +8,10 @@ data_bag_path "data_bags"
|
||||
encrypted_data_bag_secret "#{current_dir}/encrypted_data_bag_secret"
|
||||
local_mode true # Chef local mode, replacing Solo
|
||||
|
||||
# Added to /etc/chef/client.rb on node bootstrap
|
||||
# Added to /etc/cinc/client.rb on node bootstrap
|
||||
# https://docs.chef.io/attribute_persistence/
|
||||
# Source of truth: site-cookbooks/kosmos-base/files/default/chef_attributes.rb
|
||||
client_d_dir(File.expand_path("../site-cookbooks/kosmos-base/files/default/chef_attributes.rb"))
|
||||
|
||||
# Chef binaries on packages.chef.io are license-gated (HTTP 402); use the
|
||||
# community Cinc build for bootstraps and converged nodes.
|
||||
knife[:alter_project] = "cinc"
|
||||
# Cinc Workstation's knife already installs Cinc Client from omnitruck.cinc.sh
|
||||
# by default, so no `knife[:alter_project]` is needed here.
|
||||
+4
-7
@@ -1,7 +1,4 @@
|
||||
/.chef/encrypted_data_bag_secret
|
||||
/.chef/chef_guid
|
||||
/.chef/config.rb
|
||||
/.bundle/
|
||||
/.vagrant/
|
||||
/.kitchen
|
||||
/nodes/vagrant-node.json
|
||||
/.cinc/encrypted_data_bag_secret
|
||||
/.cinc/chef_guid
|
||||
/.cinc/config.rb
|
||||
.kitchen
|
||||
+1
-1
@@ -1 +1 @@
|
||||
chef-workstation
|
||||
cinc-workstation
|
||||
@@ -3,9 +3,10 @@
|
||||
Welcome, AI Agent! This file contains essential context and rules for interacting with the Kosmos Chef repository. Read this carefully before planning or executing any changes.
|
||||
|
||||
## 🏢 Project Overview
|
||||
|
||||
This repository contains the infrastructure automation code used by Kosmos to provision and configure bare metal servers (KVM hosts) and Ubuntu virtual machines (KVM guests).
|
||||
|
||||
We use **Chef Infra**, managed locally via **Knife Zero** (agentless Chef), and **Berkshelf** for dependency management.
|
||||
We use **Chef Infra**, managed locally via **Knife Zero** (agentless Chef), and **Berkshelf** for dependency management. Nodes run the community **Cinc Client** distribution (the license-free Chef Infra Client) instead of Chef Infra Client, and everything is driven by **Cinc Workstation** (the community fork of Chef Workstation). On-node configuration lives in `/etc/cinc`, and the repo's knife config lives in `.cinc/`.
|
||||
|
||||
## 📂 Directory Structure & Rules
|
||||
|
||||
@@ -13,10 +14,11 @@ We use **Chef Infra**, managed locally via **Knife Zero** (agentless Chef), and
|
||||
* **`cookbooks/`**: 🔴 **DO NOT EDIT.** This directory contains third-party/community cookbooks that are vendored. These are managed by Berkshelf. Modifying them directly will result in lost changes.
|
||||
* **`roles/`**: 🟢 **EDITABLE.** Contains Chef roles written in Ruby (e.g., `base.rb`, `kvm_guest.rb`, `postgresql_primary.rb`). These define run-lists and role-specific default attributes for servers.
|
||||
* **`environments/`**: Contains Chef environment definitions (like `production.rb`).
|
||||
* **`data_bags/`**: Contains data bag configurations, often encrypted. Be cautious and do not expose secrets. (Note: Agents should not manage data bag secrets directly unless provided the `.chef/encrypted_data_bag_secret`).
|
||||
* **`data_bags/`**: Contains data bag configurations, often encrypted. Be cautious and do not expose secrets. (Note: Agents should not manage data bag secrets directly unless provided the `.cinc/encrypted_data_bag_secret`).
|
||||
* **`nodes/`**: Contains JSON state files for bootstrapped nodes. *Agents typically do not edit these directly unless cleaning up a deleted node.*
|
||||
* **`Berksfile`**: Defines community cookbook dependencies.
|
||||
* **`Vagrantfile` / `.kitchen/`**: Used for local virtualization and integration testing.
|
||||
* **`.cinc/`**: Local knife configuration (`config.rb`, `encrypted_data_bag_secret`). Untracked; `.cinc/config.rb.example` is the template.
|
||||
* **`kitchen.yml` / `.kitchen/`**: Test Kitchen integration suites. They run against Cinc Client via Cinc Workstation's `kitchen-dokken` plugin, so invoke them with `kitchen` (see `README.md`).
|
||||
|
||||
## 🛠️ Tooling & Workflows
|
||||
|
||||
@@ -26,11 +28,15 @@ We use **Chef Infra**, managed locally via **Knife Zero** (agentless Chef), and
|
||||
- Instruct the user to run `berks install` and `berks vendor cookbooks/ --delete` (or run it via the `bash` tool if permitted).
|
||||
|
||||
2. **Provisioning (Knife Zero)**
|
||||
- Bootstrapping and converging nodes is done using `knife zero`.
|
||||
- *Example:* `knife zero converge name:server-name.kosmos.org`
|
||||
- Bootstrapping and converging nodes is done using `knife zero`.
|
||||
- *Example:* `knife zero converge -a knife_zero.host name:gitea-2`
|
||||
- *Example for a VM host/proxy (different port):* `knife zero converge -p2222 name:fornax`
|
||||
- *Example for all machines matching a role:* `knife zero converge -p2222 -a knife_zero.host 'role:openresty_proxy'`
|
||||
- To migrate an existing (Chef) node to Cinc Client: `scripts/knife/migrate_node_to_cinc.sh <node>`, then converge as usual.
|
||||
- Never converge with a reduced runlist, as it will likely impact firewall rules for other services on the same machine
|
||||
|
||||
3. **Code Style & Conventions**
|
||||
- Chef recipes, resources, and roles are written in **Ruby**.
|
||||
- Chef recipes, resources, and roles are written in **Ruby**.
|
||||
- Follow standard Chef and Ruby (RuboCop) idioms. Look at neighboring files in `site-cookbooks/` or `roles/` to match formatting and naming conventions.
|
||||
|
||||
## 🚨 Core Directives for AI Agents
|
||||
@@ -38,4 +44,4 @@ We use **Chef Infra**, managed locally via **Knife Zero** (agentless Chef), and
|
||||
1. **Infrastructure as Code**: Manual server configurations are highly discouraged. All changes must be codified in a cookbook or role.
|
||||
2. **Test Safety Nets**: Look for `.kitchen.yml` within specific `site-cookbooks/<name>` to understand if local integration tests are available.
|
||||
3. **No Assumptions**: Do not assume standard test commands. Check `README.md` and repository config files first.
|
||||
4. **Secret Handling**: Avoid hardcoding passwords or API keys in recipes or roles. Assume sensitive information is managed via Chef `data_bags`.
|
||||
4. **Secret Handling**: Avoid hardcoding passwords or API keys in recipes or roles. Assume sensitive information is managed via Chef `data_bags`.
|
||||
-440
@@ -1,440 +0,0 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
abbrev (0.1.2)
|
||||
addressable (2.9.0)
|
||||
public_suffix (>= 2.0.2, < 8.0)
|
||||
ast (2.4.3)
|
||||
aws-eventstream (1.4.0)
|
||||
aws-partitions (1.1263.0)
|
||||
aws-sdk-core (3.252.0)
|
||||
aws-eventstream (~> 1, >= 1.3.0)
|
||||
aws-partitions (~> 1, >= 1.992.0)
|
||||
aws-sigv4 (~> 1.9)
|
||||
base64
|
||||
bigdecimal
|
||||
jmespath (~> 1, >= 1.6.1)
|
||||
logger
|
||||
aws-sdk-kms (1.129.0)
|
||||
aws-sdk-core (~> 3, >= 3.248.0)
|
||||
aws-sigv4 (~> 1.5)
|
||||
aws-sdk-s3 (1.226.0)
|
||||
aws-sdk-core (~> 3, >= 3.248.0)
|
||||
aws-sdk-kms (~> 1)
|
||||
aws-sigv4 (~> 1.5)
|
||||
aws-sdk-secretsmanager (1.133.0)
|
||||
aws-sdk-core (~> 3, >= 3.248.0)
|
||||
aws-sigv4 (~> 1.5)
|
||||
aws-sigv4 (1.12.1)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
base64 (0.3.0)
|
||||
bcrypt_pbkdf (1.1.2)
|
||||
bcrypt_pbkdf (1.1.2-arm64-darwin)
|
||||
bcrypt_pbkdf (1.1.2-x86_64-darwin)
|
||||
benchmark (0.5.0)
|
||||
bigdecimal (4.1.2)
|
||||
builder (3.3.0)
|
||||
chef (19.3.15)
|
||||
addressable
|
||||
aws-sdk-s3 (~> 1.91)
|
||||
aws-sdk-secretsmanager (~> 1.46)
|
||||
bcrypt_pbkdf (~> 1.0)
|
||||
chef-config (= 19.3.15)
|
||||
chef-licensing (~> 1.3)
|
||||
chef-utils (= 19.3.15)
|
||||
chef-vault
|
||||
chef-zero (~> 15.1.0)
|
||||
corefoundation (~> 0.3.4)
|
||||
csv (~> 3.3.5)
|
||||
diff-lcs (~> 1.6.0)
|
||||
ed25519 (~> 1.2)
|
||||
erubis (~> 2.7)
|
||||
ffi (>= 1.15.5, < 1.18.0)
|
||||
ffi-libarchive (~> 1.0, >= 1.0.3)
|
||||
ffi-yajl (>= 2.2, < 4.0)
|
||||
iniparse (~> 1.4)
|
||||
inspec-core (~> 7.0.107)
|
||||
license-acceptance (>= 1.0.5, < 3)
|
||||
mixlib-archive (>= 0.4, < 2.0)
|
||||
mixlib-authentication (>= 2.1, < 4)
|
||||
mixlib-cli (>= 2.1.1, < 3.0)
|
||||
mixlib-log (>= 2.0.3, < 4.0)
|
||||
mixlib-shellout (>= 3.3.8, < 3.5.0)
|
||||
net-ftp
|
||||
net-sftp (>= 2.1.2, < 5.0)
|
||||
ohai (~> 19.0)
|
||||
plist (~> 3.2)
|
||||
proxifier2 (~> 1.1)
|
||||
syslog
|
||||
syslog-logger (~> 1.6)
|
||||
train-core (~> 3.13, >= 3.13.4)
|
||||
train-rest (>= 0.4.1)
|
||||
train-winrm (>= 0.2.17)
|
||||
unf_ext (~> 0.0.9.1)
|
||||
uri (>= 1.0.4, < 1.2.0)
|
||||
vault (>= 0.18.2, < 0.21.0)
|
||||
chef-config (19.3.15)
|
||||
addressable
|
||||
chef-utils (= 19.3.15)
|
||||
fuzzyurl
|
||||
mixlib-config (>= 2.2.12, < 4.0)
|
||||
mixlib-shellout (>= 2.0, < 4.0)
|
||||
racc
|
||||
tomlrb (>= 1.2, < 3.0)
|
||||
chef-gyoku (1.5.0)
|
||||
builder (>= 2.1.2)
|
||||
rexml (~> 3.4)
|
||||
chef-licensing (1.4.1)
|
||||
chef-config (>= 15)
|
||||
faraday (>= 1, < 3)
|
||||
faraday-http-cache
|
||||
mixlib-log (~> 3.0)
|
||||
ostruct (~> 0.6.0)
|
||||
pstore (~> 0.1.1)
|
||||
tty-prompt (~> 0.23)
|
||||
tty-spinner (~> 0.9.3)
|
||||
chef-telemetry (1.1.1)
|
||||
chef-config
|
||||
concurrent-ruby (~> 1.0)
|
||||
chef-utils (19.3.15)
|
||||
concurrent-ruby
|
||||
chef-vault (4.2.12)
|
||||
syslog (~> 0.3)
|
||||
chef-winrm (2.5.0)
|
||||
builder (>= 2.1.2)
|
||||
chef-gyoku (~> 1.5)
|
||||
erubi (~> 1.8)
|
||||
gssapi (~> 1.2)
|
||||
httpclient (~> 2.2, >= 2.2.0.2)
|
||||
logging (>= 1.6.1, < 3.0)
|
||||
nori (~> 2.7)
|
||||
rexml (>= 3.4.2, < 4.0)
|
||||
rubyntlm (~> 0.6.0, >= 0.6.3)
|
||||
chef-winrm-elevated (1.2.5)
|
||||
chef-winrm (>= 2.3.11)
|
||||
chef-winrm-fs (>= 1.3.7)
|
||||
erubi (~> 1.8)
|
||||
chef-winrm-fs (1.4.2)
|
||||
benchmark (~> 0.5.0)
|
||||
chef-winrm (~> 2.4)
|
||||
csv (~> 3.3)
|
||||
erubi (>= 1.7)
|
||||
logging (>= 1.6.1, < 3.0)
|
||||
rubyzip (~> 2.0)
|
||||
chef-zero (15.1.11)
|
||||
ffi-yajl (>= 2.2, < 4.0)
|
||||
hashie (>= 2.0, < 6.0)
|
||||
mixlib-log (>= 2.0, < 4.0)
|
||||
rack (~> 3.2, >= 3.2.6)
|
||||
rackup (~> 2.3, >= 2.3.1)
|
||||
uuidtools (>= 2.1, < 4.0)
|
||||
webrick
|
||||
coderay (1.1.3)
|
||||
concurrent-ruby (1.3.7)
|
||||
connection_pool (2.5.5)
|
||||
cookstyle (8.7.6)
|
||||
rubocop (= 1.86.1)
|
||||
corefoundation (0.3.19)
|
||||
ffi (>= 1.15.0)
|
||||
csv (3.3.5)
|
||||
date (3.5.1)
|
||||
diff-lcs (1.6.2)
|
||||
domain_name (0.6.20240107)
|
||||
ed25519 (1.4.0)
|
||||
erubi (1.13.1)
|
||||
erubis (2.7.0)
|
||||
faraday (2.14.3)
|
||||
faraday-net_http (>= 2.0, < 3.5)
|
||||
json
|
||||
logger
|
||||
faraday-follow_redirects (0.5.0)
|
||||
faraday (>= 1, < 3)
|
||||
faraday-http-cache (2.5.1)
|
||||
faraday (>= 0.8)
|
||||
faraday-net_http (3.4.4)
|
||||
net-http (~> 0.5)
|
||||
ffi (1.17.4-arm64-darwin)
|
||||
ffi (1.17.4-x86_64-darwin)
|
||||
ffi (1.17.4-x86_64-linux-gnu)
|
||||
ffi-libarchive (1.1.14)
|
||||
ffi (~> 1.0)
|
||||
ffi-yajl (2.7.11)
|
||||
libyajl2 (>= 2.1)
|
||||
fuzzyurl (0.9.0)
|
||||
gssapi (1.3.1)
|
||||
ffi (>= 1.0.1)
|
||||
hashie (5.1.0)
|
||||
logger
|
||||
highline (3.1.2)
|
||||
reline
|
||||
http-accept (1.7.0)
|
||||
http-cookie (1.1.6)
|
||||
domain_name (~> 0.5)
|
||||
httpclient (2.9.0)
|
||||
mutex_m
|
||||
iniparse (1.5.0)
|
||||
inspec-core (7.0.107)
|
||||
addressable (~> 2.4)
|
||||
chef-licensing (>= 1.2.0)
|
||||
chef-telemetry (~> 1.0, >= 1.0.8)
|
||||
cookstyle
|
||||
csv (~> 3.0)
|
||||
faraday (>= 1, < 3)
|
||||
faraday-follow_redirects (~> 0.3)
|
||||
hashie (>= 3.4, < 6.0)
|
||||
license-acceptance (>= 0.2.13, < 3.0)
|
||||
method_source (>= 0.8, < 2.0)
|
||||
mixlib-log (~> 3.0)
|
||||
multipart-post (~> 2.0)
|
||||
ostruct (>= 0.1, < 0.7)
|
||||
parallel (~> 1.9)
|
||||
parslet (>= 1.5, < 3.0)
|
||||
pry (~> 0.13)
|
||||
rspec (>= 3.9, <= 3.14)
|
||||
rspec-its (>= 1.2, < 3.0)
|
||||
rubyzip (>= 1.2.2, < 4.0)
|
||||
semverse (~> 3.0)
|
||||
sslshake (~> 1.2)
|
||||
syslog (~> 0.1)
|
||||
thor (>= 0.20, < 1.5.0)
|
||||
tomlrb (>= 1.3, < 2.1)
|
||||
train-core (~> 3.16, >= 3.16.1)
|
||||
tty-prompt (~> 0.17)
|
||||
tty-table (~> 0.10)
|
||||
io-console (0.8.2)
|
||||
ipaddress (0.8.3)
|
||||
jmespath (1.6.2)
|
||||
json (2.20.0)
|
||||
knife (19.0.134)
|
||||
abbrev
|
||||
bcrypt_pbkdf (~> 1.1)
|
||||
chef-licensing (~> 1.2)
|
||||
chef-vault
|
||||
ed25519 (>= 1.2, < 2.0)
|
||||
erubis (~> 2.7)
|
||||
ffi (>= 1.15, < 1.18.0)
|
||||
ffi-yajl (>= 2.2, < 3.0)
|
||||
highline (>= 1.6.9, < 4)
|
||||
license-acceptance (>= 1.0.5, < 3)
|
||||
mixlib-archive (>= 0.4, < 2.0)
|
||||
mixlib-cli (>= 2.1.1, < 3.0)
|
||||
net-ssh (>= 5.1, < 8)
|
||||
net-ssh-multi (~> 1.2, >= 1.2.1)
|
||||
pastel
|
||||
proxifier2 (~> 1.1)
|
||||
train-core (~> 3.13, >= 3.13.4)
|
||||
train-winrm (>= 0.2.17)
|
||||
tty-prompt (~> 0.21)
|
||||
tty-screen (~> 0.6)
|
||||
tty-table (~> 0.11)
|
||||
knife-zero (2.6.0)
|
||||
chef (>= 16.6)
|
||||
knife (>= 17.0)
|
||||
language_server-protocol (3.17.0.5)
|
||||
libyajl2 (2.1.0)
|
||||
license-acceptance (2.1.13)
|
||||
pastel (~> 0.7)
|
||||
tomlrb (>= 1.2, < 3.0)
|
||||
tty-box (~> 0.6)
|
||||
tty-prompt (~> 0.20)
|
||||
lint_roller (1.1.0)
|
||||
little-plugger (1.1.4)
|
||||
logger (1.7.0)
|
||||
logging (2.4.0)
|
||||
little-plugger (~> 1.1)
|
||||
multi_json (~> 1.14)
|
||||
method_source (1.1.0)
|
||||
mime-types (3.7.0)
|
||||
logger
|
||||
mime-types-data (~> 3.2025, >= 3.2025.0507)
|
||||
mime-types-data (3.2026.0701)
|
||||
mixlib-archive (1.3.3)
|
||||
mixlib-log
|
||||
mixlib-authentication (3.0.10)
|
||||
mixlib-cli (2.1.8)
|
||||
mixlib-config (3.0.27)
|
||||
tomlrb
|
||||
mixlib-log (3.2.3)
|
||||
ffi (>= 1.15.5)
|
||||
mixlib-shellout (3.4.10)
|
||||
chef-utils
|
||||
multi_json (1.19.1)
|
||||
multipart-post (2.4.1)
|
||||
mutex_m (0.3.0)
|
||||
net-ftp (0.3.9)
|
||||
net-protocol
|
||||
time
|
||||
net-http (0.9.1)
|
||||
uri (>= 0.11.1)
|
||||
net-http-persistent (4.0.8)
|
||||
connection_pool (>= 2.2.4, < 4)
|
||||
net-protocol (0.2.2)
|
||||
timeout
|
||||
net-scp (4.1.0)
|
||||
net-ssh (>= 2.6.5, < 8.0.0)
|
||||
net-sftp (4.0.0)
|
||||
net-ssh (>= 5.0.0, < 8.0.0)
|
||||
net-ssh (7.3.3)
|
||||
net-ssh-gateway (2.0.0)
|
||||
net-ssh (>= 4.0.0)
|
||||
net-ssh-multi (1.2.1)
|
||||
net-ssh (>= 2.6.5)
|
||||
net-ssh-gateway (>= 1.2.0)
|
||||
netrc (0.11.0)
|
||||
nori (2.7.1)
|
||||
bigdecimal
|
||||
ohai (19.1.40)
|
||||
base64
|
||||
chef-config (>= 14.12, < 20)
|
||||
chef-utils (>= 16.0, < 20)
|
||||
ffi (>= 1.15.5)
|
||||
ffi-yajl (>= 2.2, < 3.0)
|
||||
ipaddress
|
||||
mixlib-cli (>= 1.7.0)
|
||||
mixlib-config (>= 2.0, < 4.0)
|
||||
mixlib-log (>= 2.0.1, < 4.0)
|
||||
mixlib-shellout (>= 3.3.6, < 3.5.0)
|
||||
plist (~> 3.1)
|
||||
train-core
|
||||
wmi-lite (~> 1.0)
|
||||
ostruct (0.6.3)
|
||||
parallel (1.28.0)
|
||||
parser (3.3.11.1)
|
||||
ast (~> 2.4.1)
|
||||
racc
|
||||
parslet (2.0.0)
|
||||
pastel (0.8.0)
|
||||
tty-color (~> 0.5)
|
||||
plist (3.7.2)
|
||||
prism (1.9.0)
|
||||
proxifier2 (1.1.0)
|
||||
pry (0.16.0)
|
||||
coderay (~> 1.1)
|
||||
method_source (~> 1.0)
|
||||
reline (>= 0.6.0)
|
||||
pstore (0.1.4)
|
||||
public_suffix (6.0.2)
|
||||
racc (1.8.1)
|
||||
rack (3.2.6)
|
||||
rackup (2.3.1)
|
||||
rack (>= 3)
|
||||
rainbow (3.1.1)
|
||||
regexp_parser (2.12.0)
|
||||
reline (0.6.3)
|
||||
io-console (~> 0.5)
|
||||
rest-client (2.1.0)
|
||||
http-accept (>= 1.7.0, < 2.0)
|
||||
http-cookie (>= 1.0.2, < 2.0)
|
||||
mime-types (>= 1.16, < 4.0)
|
||||
netrc (~> 0.8)
|
||||
rexml (3.4.4)
|
||||
rspec (3.13.2)
|
||||
rspec-core (~> 3.13.0)
|
||||
rspec-expectations (~> 3.13.0)
|
||||
rspec-mocks (~> 3.13.0)
|
||||
rspec-core (3.13.6)
|
||||
rspec-support (~> 3.13.0)
|
||||
rspec-expectations (3.13.5)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.13.0)
|
||||
rspec-its (2.0.0)
|
||||
rspec-core (>= 3.13.0)
|
||||
rspec-expectations (>= 3.13.0)
|
||||
rspec-mocks (3.13.8)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.13.0)
|
||||
rspec-support (3.13.7)
|
||||
rubocop (1.86.1)
|
||||
json (~> 2.3)
|
||||
language_server-protocol (~> 3.17.0.2)
|
||||
lint_roller (~> 1.1.0)
|
||||
parallel (>= 1.10)
|
||||
parser (>= 3.3.0.2)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
regexp_parser (>= 2.9.3, < 3.0)
|
||||
rubocop-ast (>= 1.49.0, < 2.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 2.4.0, < 4.0)
|
||||
rubocop-ast (1.49.1)
|
||||
parser (>= 3.3.7.2)
|
||||
prism (~> 1.7)
|
||||
ruby-progressbar (1.13.0)
|
||||
rubyntlm (0.6.5)
|
||||
base64
|
||||
rubyzip (2.4.1)
|
||||
semverse (3.0.2)
|
||||
socksify (1.8.1)
|
||||
sslshake (1.3.1)
|
||||
strings (0.2.1)
|
||||
strings-ansi (~> 0.2)
|
||||
unicode-display_width (>= 1.5, < 3.0)
|
||||
unicode_utils (~> 1.4)
|
||||
strings-ansi (0.2.0)
|
||||
syslog (0.4.0)
|
||||
logger
|
||||
syslog-logger (1.6.8)
|
||||
thor (1.4.0)
|
||||
time (0.4.2)
|
||||
date
|
||||
timeout (0.6.1)
|
||||
tomlrb (2.0.4)
|
||||
train-core (3.16.5)
|
||||
addressable (~> 2.5)
|
||||
ffi (>= 1.16.0, < 1.18)
|
||||
json (>= 2.19.2, < 3.0)
|
||||
mixlib-shellout (>= 2.0, < 4.0)
|
||||
net-scp (>= 1.2, < 5.0)
|
||||
net-ssh (>= 2.9, < 8.0)
|
||||
train-rest (0.5.0)
|
||||
aws-sigv4 (~> 1.5)
|
||||
rest-client (~> 2.1)
|
||||
train-core (~> 3.0)
|
||||
train-winrm (0.4.3)
|
||||
chef-winrm (>= 2.4.4, < 3.0)
|
||||
chef-winrm-elevated (>= 1.2.5, < 2.0)
|
||||
chef-winrm-fs (>= 1.4.1, < 2.0)
|
||||
socksify (~> 1.8)
|
||||
tty-box (0.7.0)
|
||||
pastel (~> 0.8)
|
||||
strings (~> 0.2.0)
|
||||
tty-cursor (~> 0.7)
|
||||
tty-color (0.6.0)
|
||||
tty-cursor (0.7.1)
|
||||
tty-prompt (0.23.1)
|
||||
pastel (~> 0.8)
|
||||
tty-reader (~> 0.8)
|
||||
tty-reader (0.9.0)
|
||||
tty-cursor (~> 0.7)
|
||||
tty-screen (~> 0.8)
|
||||
wisper (~> 2.0)
|
||||
tty-screen (0.8.2)
|
||||
tty-spinner (0.9.3)
|
||||
tty-cursor (~> 0.7)
|
||||
tty-table (0.12.0)
|
||||
pastel (~> 0.8)
|
||||
strings (~> 0.2.0)
|
||||
tty-screen (~> 0.8)
|
||||
unf_ext (0.0.9.1)
|
||||
unicode-display_width (2.6.0)
|
||||
unicode_utils (1.4.0)
|
||||
uri (1.1.1)
|
||||
uuidtools (3.0.0)
|
||||
vault (0.20.1)
|
||||
aws-sigv4
|
||||
base64
|
||||
net-http-persistent (~> 4.0, >= 4.0.2)
|
||||
webrick (1.9.2)
|
||||
wisper (2.0.1)
|
||||
wmi-lite (1.0.7)
|
||||
|
||||
PLATFORMS
|
||||
arm64-darwin-22
|
||||
x86_64-darwin-18
|
||||
x86_64-darwin-19
|
||||
x86_64-linux
|
||||
|
||||
DEPENDENCIES
|
||||
knife-zero (~> 2.6.0)
|
||||
|
||||
BUNDLED WITH
|
||||
2.2.15
|
||||
@@ -2,45 +2,61 @@ This repository contains all infrastructure automation code that we use to set
|
||||
up and configure servers, virtual machines, and applications for Kosmos hosted
|
||||
services.
|
||||
|
||||
Chef cookbooks are written in Ruby, and based on [Chef Infra
|
||||
Cookbooks are written in Ruby, and based on [Chef Infra
|
||||
resources](https://docs.chef.io/resources/). Some cookbooks contain integration
|
||||
test suites based on [Test Kitchen](https://docs.chef.io/workstation/kitchen/).
|
||||
|
||||
Nodes run the community [Cinc Client](https://cinc.sh/) distribution of Chef
|
||||
Infra Client instead of the license-gated Chef Infra Client. Everything — the
|
||||
`knife zero` workflow and the Test Kitchen suites — is driven by
|
||||
[Cinc Workstation](https://cinc.sh/docs/workstation/), and on-node
|
||||
configuration lives in `/etc/cinc`.
|
||||
|
||||
Note: Manual configuration of servers and applications is highly discouraged,
|
||||
and can be overwritten or lost without notice!
|
||||
|
||||
## Setup
|
||||
|
||||
### Install Chef Workstation
|
||||
### Install Cinc Workstation
|
||||
|
||||
* macOS, Windows, RHEL, Ubuntu: https://docs.chef.io/workstation/install_workstation/
|
||||
* Arch Linux: https://aur.archlinux.org/packages/chef-workstation
|
||||
Cinc Workstation replaces Chef Workstation. Install it following
|
||||
https://cinc.sh/docs/workstation/ — or, on Arch Linux, the `cinc-workstation-bin`
|
||||
AUR package. It installs to `/opt/cinc-workstation` and reads its user config
|
||||
from `~/.cinc-workstation`.
|
||||
|
||||
#### rbenv
|
||||
|
||||
If you use rbenv to manage Ruby versions on your system, install the
|
||||
[rbenv-chef-workstation](https://github.com/docwhat/rbenv-chef-workstation)
|
||||
plugin.
|
||||
`rbenv-cinc-workstation` plugin (the Cinc port of
|
||||
[rbenv-chef-workstation](https://github.com/docwhat/rbenv-chef-workstation)),
|
||||
create an empty `$(rbenv root)/versions/cinc-workstation` directory, and run
|
||||
`rbenv rehash`. This repository pins the version in `.ruby-version`.
|
||||
|
||||
### Install gem dependencies
|
||||
### Install knife-zero
|
||||
|
||||
Clone this repository, `cd` into it, and run:
|
||||
`knife-zero` is not bundled with Cinc Workstation. Install it into Cinc's user
|
||||
gem directory:
|
||||
|
||||
bundle install
|
||||
cinc gem install knife-zero
|
||||
|
||||
### Configure knife
|
||||
|
||||
Copy `.cinc/config.rb.example` to `.cinc/config.rb` and adjust
|
||||
`encrypted_data_bag_secret` if your secret lives elsewhere.
|
||||
|
||||
## Common tasks
|
||||
|
||||
### Bootstrap a new host server
|
||||
|
||||
knife zero bootstrap root@server-name.kosmos.org --run-list "role[base],role[kvm_host]" --secret-file .chef/encrypted_data_bag_secret
|
||||
knife zero bootstrap root@server-name.kosmos.org --run-list "role[base],role[kvm_host]" --secret-file .cinc/encrypted_data_bag_secret
|
||||
|
||||
### Bootstrap a new VM
|
||||
|
||||
knife zero bootstrap ubuntu@zerotier-ip-address -x ubuntu --sudo --run-list "role[base],role[kvm_guest]" --secret-file .chef/encrypted_data_bag_secret
|
||||
knife zero bootstrap ubuntu@zerotier-ip-address -x ubuntu --sudo --run-list "role[base],role[kvm_guest]" --secret-file .cinc/encrypted_data_bag_secret
|
||||
|
||||
### Bootstrap a new VM with environment and role/app (postgres replica as example)
|
||||
|
||||
knife zero bootstrap ubuntu@10.1.1.134 -x ubuntu --sudo --environment production --run-list "role[base],role[kvm_guest],role[postgresql_replica]" --secret-file .chef/encrypted_data_bag_secret
|
||||
knife zero bootstrap ubuntu@10.1.1.134 -x ubuntu --sudo --environment production --run-list "role[base],role[kvm_guest],role[postgresql_replica]" --secret-file .cinc/encrypted_data_bag_secret
|
||||
|
||||
### Run Chef Zero on a host server
|
||||
|
||||
@@ -50,13 +66,22 @@ Clone this repository, `cd` into it, and run:
|
||||
|
||||
knife zero converge -a knife_zero.host name:vm-name-23
|
||||
|
||||
### Update Chef Client on a server:
|
||||
### Update Cinc Client on a server
|
||||
|
||||
knife zero converge name:dev.kosmos.org --client-version 15.3.14
|
||||
knife zero converge name:dev.kosmos.org --client-version latest
|
||||
|
||||
### Upgrade Chef Client on a node:
|
||||
### Upgrade Cinc Client on a node
|
||||
|
||||
knife ssh -a knife_zero.host 'name:foo-1' 'curl -L https://chef.io/chef/install.sh | sudo bash -s -- -v 18.10.17'
|
||||
knife ssh -a knife_zero.host 'name:foo-1' 'curl -L https://omnitruck.cinc.sh/install.sh | sudo bash -s -- -v latest'
|
||||
|
||||
The migration script (below) installs the **current stable** Cinc Client for the
|
||||
node's platform (`-v latest`); omnitruck picks the right build per OS. Pass a
|
||||
concrete version (e.g. `-v 19.2.12`) instead of `latest` if you need a true
|
||||
freeze.
|
||||
|
||||
### Migrate an existing node to Cinc Client
|
||||
|
||||
scripts/knife/migrate_node_to_cinc.sh node-name-1 # then converge as usual
|
||||
|
||||
## Managing cookbooks
|
||||
|
||||
@@ -70,13 +95,12 @@ Vendor installed cookbooks to the `cookbooks/` dir:
|
||||
|
||||
berks vendor cookbooks/ --delete
|
||||
|
||||
## "Expired" TLS certificates
|
||||
## Integration tests
|
||||
|
||||
If you encounter expired TLS certificates during a Chef run (e.g. for remote
|
||||
files), the issue is likely that the certificate has been issued by Let's
|
||||
Encrypt and Chef is still using its own, outdated CA cert store (see
|
||||
[here](https://github.com/chef/chef/issues/12126#issuecomment-932067530) for
|
||||
example).
|
||||
Some cookbooks contain Test Kitchen suites. They are configured to run against
|
||||
Cinc Client (`provisioner: product_name: cinc`) and use Cinc Workstation's
|
||||
bundled `kitchen` (which ships a Cinc-capable `kitchen-dokken`):
|
||||
|
||||
As a hotfix, you can manually remove the "DST Root CA X3" cert from
|
||||
`/opt/chef/embedded/ssl/cert.pem` on the machine you're trying to converge.
|
||||
kitchen test
|
||||
|
||||
(use `kitchen converge`/`verify` while iterating on a single suite).
|
||||
Vendored
-92
@@ -1,92 +0,0 @@
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
||||
# configures the configuration version.
|
||||
#
|
||||
# Documentation for all configuration options can be found here:
|
||||
# https://www.vagrantup.com/docs/vagrantfile
|
||||
Vagrant.configure(2) do |config|
|
||||
|
||||
config.vm.provider :virtualbox do |vb|
|
||||
vb.memory = "1024"
|
||||
vb.cpus = 2
|
||||
end
|
||||
|
||||
# config.vm.provider :docker do |d, override|
|
||||
# d.image = "nishidayuya/docker-vagrant-ubuntu:xenial"
|
||||
# d.has_ssh = true
|
||||
# override.vm.box = nil
|
||||
# override.ssh.port = 22
|
||||
# end
|
||||
|
||||
config.vm.define "ldap" do |ldap|
|
||||
ldap.vm.box = "bento/ubuntu-18.04"
|
||||
ldap.vm.network "forwarded_port", guest: 389, host: 389
|
||||
ldap.vm.network "private_network", ip: "192.168.56.5"
|
||||
|
||||
ldap.vm.provision :chef_zero do |chef|
|
||||
chef.version = "18.2.7"
|
||||
chef.node_name = "vagrant-node-ldap"
|
||||
chef.arguments = "--chef-license accept"
|
||||
chef.cookbooks_path = ["cookbooks", "site-cookbooks"]
|
||||
chef.data_bags_path = "data_bags"
|
||||
chef.roles_path = "roles"
|
||||
chef.nodes_path = "nodes"
|
||||
chef.environments_path = "environments"
|
||||
chef.encrypted_data_bag_secret_key_path = ".chef/encrypted_data_bag_secret"
|
||||
chef.environment = "development"
|
||||
|
||||
chef.add_recipe "kosmos-base"
|
||||
chef.add_recipe "kosmos-dirsrv"
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "bitcoin" do |bitcoin|
|
||||
bitcoin.vm.box = "generic/ubuntu2004"
|
||||
bitcoin.vm.network "forwarded_port", guest: 4201, host: 4201
|
||||
bitcoin.vm.network "private_network", ip: "192.168.56.6"
|
||||
# bitcoin.vm.synced_folder "../kredits/yap/", "/opt/yap"
|
||||
|
||||
bitcoin.vm.provision :chef_zero do |chef|
|
||||
chef.version = "18.2.7"
|
||||
chef.node_name = "vagrant-node-bitcoin"
|
||||
chef.arguments = "--chef-license accept"
|
||||
chef.cookbooks_path = ["cookbooks", "site-cookbooks"]
|
||||
chef.data_bags_path = "data_bags"
|
||||
chef.roles_path = "roles"
|
||||
chef.nodes_path = "nodes"
|
||||
chef.environments_path = "environments"
|
||||
chef.encrypted_data_bag_secret_key_path = ".chef/encrypted_data_bag_secret"
|
||||
chef.environment = "development"
|
||||
|
||||
chef.add_recipe "kosmos-base"
|
||||
chef.add_recipe "kosmos-bitcoin::source"
|
||||
# chef.add_recipe "kosmos-bitcoin::foo"
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "openresty" do |openresty|
|
||||
openresty.vm.box = "bento/ubuntu-20.04"
|
||||
openresty.vm.network "forwarded_port", guest: 6379, host: 6379
|
||||
openresty.vm.network "private_network", ip: "192.168.56.7"
|
||||
|
||||
openresty.vm.provision :chef_zero do |chef|
|
||||
chef.version = "18.2.7"
|
||||
chef.node_name = "vagrant-openresty"
|
||||
chef.arguments = "--chef-license accept"
|
||||
chef.cookbooks_path = ["cookbooks", "site-cookbooks"]
|
||||
chef.data_bags_path = "data_bags"
|
||||
chef.roles_path = "roles"
|
||||
chef.nodes_path = "nodes"
|
||||
chef.environments_path = "environments"
|
||||
chef.encrypted_data_bag_secret_key_path = ".chef/encrypted_data_bag_secret"
|
||||
chef.environment = "development"
|
||||
|
||||
chef.add_recipe "kosmos-base"
|
||||
chef.add_role "openresty"
|
||||
chef.add_role "openresty_proxy"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,58 +1,65 @@
|
||||
{
|
||||
"id": "gitea",
|
||||
"jwt_secret": {
|
||||
"encrypted_data": "wMxs1Ec4vKRSzFtL2KuU1XfmR1t5KDx/7XBbI7V0QfgK+JwYbxU5w6feQCBE\nxOMepAXVUwU7RxPZ+hwQgPg=\n",
|
||||
"iv": "F4vtuOL2B9e9LQnb\n",
|
||||
"auth_tag": "NHATxHbr+3Y3Kxa68NwnjQ==\n",
|
||||
"encrypted_data": "fZnJWLiiqzUpFtNirS33sclrlHmXPzKyMiIujp1hmwqWw6b3/ySeam4R/9F0\nqLr1jnW+fDmYmdUW6wPoFGk=\n",
|
||||
"iv": "Wx88w/nBFI50Ej0b\n",
|
||||
"auth_tag": "5JjuZuwouAvoMDk2LgAoLQ==\n",
|
||||
"version": 3,
|
||||
"cipher": "aes-256-gcm"
|
||||
},
|
||||
"internal_token": {
|
||||
"encrypted_data": "mlvUtIjs6kcv7XcYCUOgOE/kDSE4Ts5G+CZuPrJapW9XwkebmyOnHJvXdihY\np/chUtar0pNB5Q16LeeZF9KrzOiDo/OXb40TPUzpsB0/607zV1z829STd4l7\nu5g4Zur13nxC9jT0zQL9QgDEobYdjgf/xu1BXxFT+Ue3lQ==\n",
|
||||
"iv": "25+1a2OJYFNxdf1N\n",
|
||||
"auth_tag": "aF8Gn6Mm7AwLjbR8cDnitg==\n",
|
||||
"encrypted_data": "ASlbrrBLfMpuAHma3ApAs7I9Lm0xuUvLBz1IfNuaarjliQczOehbmZsqS883\nqCRV/rGwE8BO33VBTqmB49KUyee7B+KFbzyTVkXjrpHRofY4LOcYW7/OfMJP\n+hfAnWAlZeQud3Z8IfusXGDVHQ3U5ebFTwSaAMuMj4fPzg==\n",
|
||||
"iv": "UHIYNKU0OUNjY3sN\n",
|
||||
"auth_tag": "3laBspfgWoYdZqBD5pHVAA==\n",
|
||||
"version": 3,
|
||||
"cipher": "aes-256-gcm"
|
||||
},
|
||||
"secret_key": {
|
||||
"encrypted_data": "xQuHuijNHoo2WicM2UvSGpwPHd0UilxlIl4BM2Rgyih5bdhjxB6UtUcY9uJQ\nYgxEd7y7R5+XhUAu87CEs4qAGtguDDxGtSGwgTSopvAYZewPFLw=\n",
|
||||
"iv": "Kxwqagjps8kP7Dhz\n",
|
||||
"auth_tag": "WGz5TzBzksf36hKPzBZTQQ==\n",
|
||||
"encrypted_data": "4BVf7PGXARAaZbX7226LCF5xEpPhexxcLLfvGodGNuBjSOEliTXsQiHdFTIj\ng5nJzXx4D4sjhvY4FgcNEhVUreBWYke8dn0L3uz5xiogFSLtHlU=\n",
|
||||
"iv": "JCJJRAS2iDRIo9U2\n",
|
||||
"auth_tag": "i2mcB9IQWlXlavZ2zycoBw==\n",
|
||||
"version": 3,
|
||||
"cipher": "aes-256-gcm"
|
||||
},
|
||||
"postgresql_password": {
|
||||
"encrypted_data": "ZziPtXhQM/TQBE+077smnjEPzfJOSo9Cj/CUnG/Be1AN0UAfielf68EhLg==\n",
|
||||
"iv": "iBdSrY15vOc3eycF\n",
|
||||
"auth_tag": "km2CkraKlpOygaz7Xy548Q==\n",
|
||||
"encrypted_data": "5855l2MyYjqg/kUPyGPFcoqbObJZh/v79wFBAaBy0Vhe9VAo/G/1tqvvgA==\n",
|
||||
"iv": "xwK5hEkkROs16hma\n",
|
||||
"auth_tag": "sAPM/xsMMmoK71pj+5DqEQ==\n",
|
||||
"version": 3,
|
||||
"cipher": "aes-256-gcm"
|
||||
},
|
||||
"s3_key_id": {
|
||||
"encrypted_data": "1j0znqBgNbHMyJIf51MmfkjkpU3SPv+EL8F30mrfQ44vsGziyeiWfp91hGUM\n",
|
||||
"iv": "dzJM1EX/X8Qy5KbR\n",
|
||||
"auth_tag": "2YUCCFG/oTph3svFYhhYzg==\n",
|
||||
"encrypted_data": "K5fgxcHgxGcgDro96mgIowHJD6FFdea/+DtNyT8YMZ9OnrwBPWQTTtJqMpol\n",
|
||||
"iv": "EZmdjcXjGUFKi5xP\n",
|
||||
"auth_tag": "mRdO3XjYr2z+EZeEiorh/A==\n",
|
||||
"version": 3,
|
||||
"cipher": "aes-256-gcm"
|
||||
},
|
||||
"s3_secret_key": {
|
||||
"encrypted_data": "7P3JUyl0LsGuGi8GhSYdXHm4bQhnkGfSrbEMGyfzjSYB5hqm17kYZwNbNA0O\nIUmJ6Kq9Nby7IFTd1qFo7aA+dXuvxJD5QXO8T5E+D0xIaWMHPco=\n",
|
||||
"iv": "+ivHjYpQG/3gQWAi\n",
|
||||
"auth_tag": "fftxN0Z/Kfrn+oFk07jKYQ==\n",
|
||||
"encrypted_data": "S7xrrCDLuhOpprDNFTM/8ME2vDK3U2bhCKQalsFrxbsv1+ogHllF/G5zrL1p\n5H0pMkeDDvgN3oNNr2UbmYJJnmyyZyWDy5m1Dv9BiIv20RY1ucc=\n",
|
||||
"iv": "nANI8bJR5UOd0YCP\n",
|
||||
"auth_tag": "Wlkr2dEYJ2ytMO28VL8aKw==\n",
|
||||
"version": 3,
|
||||
"cipher": "aes-256-gcm"
|
||||
},
|
||||
"s3_bucket": {
|
||||
"encrypted_data": "98UnmjwIlLjNFQojZlQRMZAWpI/7s9xJkgvh4sU5I2jWmYk=\n",
|
||||
"iv": "zLck9Dp6OP+L3BwX\n",
|
||||
"auth_tag": "Zc5G6bd7CbZfDCZ31YWxMg==\n",
|
||||
"encrypted_data": "l9icd2M+a+P1japoRLGEYOXtkuMLnuotsE4nWyXER+i+XZE=\n",
|
||||
"iv": "922rYakCutpFO5aP\n",
|
||||
"auth_tag": "zDanzudY8PBBZBRGHvU6Hg==\n",
|
||||
"version": 3,
|
||||
"cipher": "aes-256-gcm"
|
||||
},
|
||||
"runners": {
|
||||
"encrypted_data": "f0RRLCrGT7LDUEXcM6m2dJ7C95UPqVZz9dfNLsYa/3SZLDcm1p4FDIy0Su6R\nrXMoAI9IdLBN7/BDMMvqkULEq3Bx5vXn+oTUsUYuKxWmvKEUhC4virOApxh6\n5GbuqcOEPKaf9lHByL+2HKdAmJMzVRGD0t78ePS2pU4H6IFnS9V1p6opOEPr\nzTJ+0PM98eQ/voFKDHGNHUqgDs2qu9wUYNmcHe1eSimFdJiOCN0Mlszu3HL0\nXkHfrGbLrcW+8Ol7dTXdDJB7WAd3R3vddoZQ+mrwzGGDeSMm+ezeMzAX\n",
|
||||
"iv": "NtZ9SbbscX47BXGH\n",
|
||||
"auth_tag": "ZGBzxjNFB5WPnJCpdFwtAQ==\n",
|
||||
"encrypted_data": "KR6YIzLKjcERHjwda5GHVN77qX6CDC/ihIRy8hZxoiRb+o+i3lJW3cX0EiM2\n36iK1apHRXZWCz7eM1SPRVU9AH/S4yaUBi/dhIvqta011KI2I8bgtkKvU9Af\nvemkIFfyDiq+fFU3irNoiK5tzUuU9FlwdCdohkZMINorcJq87cIvvzF5pDVv\niMLFqbRr7i4tUO9KYUGG6rnndz7crw/gjm6da64N9qSUKfxaaejjzT/ouruo\nxn8mJmHEfPyUf0A8mn/0p6VEnP/5AX5+YPRrOvuv2LxskpKp0hsIe7hU\n",
|
||||
"iv": "eJVs/QvBuWfQO3k1\n",
|
||||
"auth_tag": "crTUFAioi9e8k5I9TcTl3g==\n",
|
||||
"version": 3,
|
||||
"cipher": "aes-256-gcm"
|
||||
},
|
||||
"bot_filter": {
|
||||
"encrypted_data": "lo3Nr87mIoMbjpQ2/Txc5MdWM3OPVEwZKCe2Uz+vkjjW4tVe7SzcJgQABR28\ng8nZfHRHPtwi5FJbEvOXDMAnQGduVoI/GMF+Be1OiS7efqZQ2qI4psGTrotc\nQmCbYr6XOXKz7v06y0i9pWZxBnZMr8j95ts5J5XWX9lc5pVY8q0ujm7j9Yb4\ntSUByBUCGJYkCg8uMqNMFEickBKsQodMlT/2VyYG/gFwEjUsB9f0COpTL1zN\n1hdWUtzk0eXVxmB50USYYrPQzgQrAQ0XwEkEq8mLeb7cAhGskQn7DNU+cZOZ\nCvtv2GzbSCIOAMgV5S4W23yZQUiaiB/B4t8jBrzoa4af91xJ228OUNGlCEUm\ncQB9f/0Zf9fRelOd/hpXqOakP4CfIVDBI/TOkFsQn2FurE2ndWZCzqqoFg3U\nR1fh1pwUbDc/n0Oi3L2g9fJlC3HzYmesgIpKYVp1Lak0w5093ewXQ3EeBD98\nRic+NNDAgeKkUQnLtNKTvjQFlYv+LYCaAyvMROfBLbr0iNtravB2QMchL104\nd7UYjw4VYThvcr7Wn/y7znmCyfXISDCrRd7x+4K0laSGSwnPrKqmmC+N+jxB\n2ydNf6zGZefcot2AIvxaKwV1kTsl5cxsH/cYrFsG2RvruPAqLAIDN06mT/Nz\nxJE=\n",
|
||||
"iv": "If2EG9k+nEFssls0\n",
|
||||
"auth_tag": "/2DlnFtWYLzJiJrS4Jm3Vg==\n",
|
||||
"version": 3,
|
||||
"cipher": "aes-256-gcm"
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
{
|
||||
"id": "liquor-cabinet",
|
||||
"s3_access_key": {
|
||||
"encrypted_data": "TKYUWVboQZUKvw4bqrKsL28dH2DGR5iDBQclAwm5I7GqkxFfkG2d91qLv+BA\n",
|
||||
"iv": "B8YYzXeFGxMG34WI\n",
|
||||
"auth_tag": "HOIfcpJOFYIVvf5o8lk4mg==\n",
|
||||
"encrypted_data": "OLx6rlsOpI6CEJoDKK8NzF9o5PZzjKW7euQ1DOaVV+zWgxqdDn0Ow2iDhy6L\n",
|
||||
"iv": "DC8MCr3dAgOtmumh\n",
|
||||
"auth_tag": "bCZAYhWPipCy/jkY5hofoA==\n",
|
||||
"version": 3,
|
||||
"cipher": "aes-256-gcm"
|
||||
},
|
||||
"s3_secret_key": {
|
||||
"encrypted_data": "GRqGJkGJ/f0zQVtO0r9TcXBqlpnfC5PiwTZK8QmsqEhzQI6U67NAf62QqTgl\nGVI1h8G5ITgC3l0xVhcvH6m2bcs9fjNzFIqnhoZhzGwEt51A5Zk=\n",
|
||||
"iv": "UAlmoUWLedpd79xa\n",
|
||||
"auth_tag": "2F/EJhY5/59dtFFwkd106A==\n",
|
||||
"encrypted_data": "4ZGXnzuoCNRhFrOapt6dFagJjhb4nzMFqRfdsaUI7tzbV1Xvvp63MUs/z7UT\nUp0vJyTDAKTTZ5AV0BWz+HWzQ3Wkk3EgGd7FGJrLzuwXe2MuEFE=\n",
|
||||
"iv": "aqh92wCSwywZtKda\n",
|
||||
"auth_tag": "AshKWo/k4fv0iofsVov1OA==\n",
|
||||
"version": 3,
|
||||
"cipher": "aes-256-gcm"
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@ The admin account is `cn=Directory Manager` with the password stored in the
|
||||
encrypted data bag `admin_password` item
|
||||
|
||||
```
|
||||
$ knife data bag show credentials dirsrv --secret-file .chef/encrypted_data_bag_secret
|
||||
$ knife data bag show credentials dirsrv --secret-file .cinc/encrypted_data_bag_secret
|
||||
```
|
||||
|
||||
## Example search (will prompt for password):
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
# Nostr submission relay (Chef)
|
||||
|
||||
Chef-side pieces of the public submission relay + image-recognition moderation
|
||||
MVP ([`raucao/marco#97`](https://gitea.kosmos.org/raucao/marco/issues/97)). The
|
||||
canonical plan/spec lives in the Marco repo, `doc/nostr/submission-relay-mvp/`.
|
||||
|
||||
This document is the Chef runbook: what the code deploys, how it was rolled out,
|
||||
and how to roll it back. **The stack is deployed to production** — the relay is
|
||||
live at `wss://submit.nostr.kosmos.org` and both promotion paths are enabled.
|
||||
The deployment order below is kept as a record of the rollout and for rebuilding
|
||||
the service elsewhere.
|
||||
|
||||
## What the Chef code adds
|
||||
|
||||
| Piece | Where | Recipe / role |
|
||||
| --- | --- | --- |
|
||||
| Public submission relay (strfry #2, `:7778`) | one node | `role[strfry_submission]` → `kosmos_strfry_submission::default` |
|
||||
| Firewall for `:7778` | same node | `kosmos_strfry_submission::firewall` |
|
||||
| `wss://submit.nostr.kosmos.org` vhost + cert | openresty proxy nodes | `kosmos_strfry_submission::nginx` (via `role[openresty_proxy]`) |
|
||||
| Approved-event sync (staging `:7779` → production DB) | production relay node | `kosmos_strfry::approved_sync` (via `role[strfry]`) |
|
||||
| Member bridge (`:7778` → production DB, LDAP-only) | production relay node | `kosmos_strfry::member_bridge` (via `role[strfry]`) |
|
||||
| Node 24 LTS for the Node write policies | relay nodes | role-scoped `kosmos_nodejs.version` override |
|
||||
|
||||
Write policies from `kosmos/akkounts` `extras/strfry/` are fetched at converge
|
||||
time:
|
||||
|
||||
* `submission-policy.mjs` — open write gates for the submission relay (Node).
|
||||
* `sync-policy.mjs` — fail-closed policy for `strfry sync` (Node; see below).
|
||||
* `ldap-only-policy.ts` — LDAP membership gate for the member bridge (Deno; see
|
||||
below).
|
||||
|
||||
## Design notes / invariants
|
||||
|
||||
* **The submission relay is not `role[strfry].`** The openresty proxy builds its
|
||||
production `_strfry` upstream from `role:strfry`; a submission node must never
|
||||
be added to it. The new role also avoids `role[ldap_client]`, because the
|
||||
submission relay is open to all authors and does not do LDAP.
|
||||
* **The sync is the only non-member write path into production.** It runs
|
||||
`strfry --config /etc/strfry-sync.conf sync <staging> --dir down`, one-way,
|
||||
every 5 minutes. `strfry sync --dir down` runs the *local* write policy with
|
||||
`sourceType="Sync"` and `sourceInfo=<remote relay URL>`
|
||||
(`src/apps/mesh/cmd_sync.cpp`), so `sync-policy.mjs` can accept only that exact
|
||||
source and reject everything else. `STAGING_RELAY_URL` is passed to the unit
|
||||
and must byte-match the URL on the command line — both come from the single
|
||||
`node["strfry"]["staging_relay_url"]` attribute.
|
||||
* **The sync uses the production database** (`node["strfry"]["config"]["db"]`)
|
||||
with a 100-year age floor (`rejectEventsOlderThanSeconds = 3153600000`) so
|
||||
long-delayed approvals still land. Note that `0` does **not** disable this
|
||||
check in strfry: strfry computes `earliest = now - rejectEventsOlderThanSeconds`,
|
||||
so `0` makes `earliest == now` and rejects every event as "created_at too
|
||||
early" *before the write policy runs*. A large bound is the way to turn it off.
|
||||
* **The sync config sets `nofiles` explicitly.** strfry raises its `RLIMIT_NOFILE`
|
||||
to `relay.nofiles` at startup and exits if that exceeds the process hard limit.
|
||||
The compiled-in default (1000000) is above the systemd default here (524288),
|
||||
so `strfry_sync.conf.erb` sets `nofiles = <production value or 524288>`. Without
|
||||
it the sync fails to start with `Unable to set NOFILES limit to 1000000`.
|
||||
* **The submission relay is reachable only from the openresty proxy nodes.**
|
||||
The relay trusts nginx's `X-Real-IP` (`realIpHeader = "x-real-ip"`), so a
|
||||
direct connection could forge that header and defeat the policy's per-IP token
|
||||
bucket. `kosmos_strfry_submission::firewall` therefore allow-lists the ZT IPs
|
||||
of the `role:openresty_proxy` nodes instead of all of `10.1.1.0/24` (the
|
||||
per-author bucket is unaffected). Consequence: anything that talks to the
|
||||
relay *directly* over ZeroTier must be added explicitly — in particular, if
|
||||
the WS2 moderator is switched from `wss://submit.nostr.kosmos.org` to the
|
||||
ZT-direct `ws://<relay>:7778`, add the nuc's address to the allow-list (or
|
||||
route it through nginx). The member bridge uses loopback and is unaffected.
|
||||
* **No `--filter` on the sync.** The worker only publishes approved events to
|
||||
the staging relay; the policy is the gate.
|
||||
* **The member bridge is a live `strfry router`, not a service.** A stream group
|
||||
with `dir = "down"` subscribes to `ws://localhost:7778` and writes
|
||||
member-authored events into the production LMDB; its `pluginDown` is
|
||||
`ldap-only-policy.ts`, so membership is decided per event by LDAP and no member
|
||||
list is maintained. The group's `filter` bounds the REQ (and therefore the LDAP
|
||||
lookups) to the submission kinds. `dir = "down"` makes it strictly one-way: the
|
||||
router never watches or forwards the local DB. `pluginDown`'s path contains no
|
||||
spaces, so strfry watches its mtime and hot-reloads it without a restart. It
|
||||
writes to the same LMDB as the relay (the same multi-process access pattern as
|
||||
the approved sync).
|
||||
* **Both promotion paths are enabled from `role[strfry_submission]`.** The
|
||||
`strfry.approved_sync.enabled` and `strfry.member_bridge.enabled` switches are
|
||||
set as role overrides, not in the production environment, so they travel with
|
||||
this feature's roles. (The recipes themselves live in `role[strfry]`; the relay
|
||||
node runs both roles.)
|
||||
|
||||
## Attributes
|
||||
|
||||
| Attribute | Default | Notes |
|
||||
| --- | --- | --- |
|
||||
| `strfry.staging_relay_url` | `ws://10.1.1.183:7779` | nuc ZeroTier IP + staging port |
|
||||
| `strfry.approved_sync.enabled` | `false` | **no-op until enabled** (`true` in `role[strfry_submission]`) |
|
||||
| `strfry.member_bridge.enabled` | `false` | **no-op until enabled** (`true` in `role[strfry_submission]`) |
|
||||
| `strfry.member_bridge.subscribe_relay` | `ws://localhost:7778` | local submission relay |
|
||||
| `strfry.member_bridge.plugin_cmd` | `/opt/strfry/ldap-only-policy.ts` | LDAP-only `pluginDown` |
|
||||
| `strfry.member_bridge.kinds` | `[0, 3, 5, 360, 30360]` | router REQ kind filter |
|
||||
| `strfry_submission.domain` | `submit.nostr.kosmos.org` | |
|
||||
| `strfry_submission.port` | `7778` | |
|
||||
| `strfry_submission.config.db_params.mapsize` | `4 GiB` | disk cap for the disposable DB |
|
||||
|
||||
## Regression checks
|
||||
|
||||
`site-cookbooks/kosmos_strfry/test/strfry_sync_conf_test.rb` renders
|
||||
`strfry_sync.conf.erb` with the attribute shapes `approved_sync.rb` passes and
|
||||
fails if the sync config's `rejectEventsOlderThanSeconds` is missing or `<= 0`
|
||||
(the guard for the "0 rejects every event" trap above) or if `nofiles` is not
|
||||
set to the expected value (strfry exits at startup when its `nofiles` exceeds
|
||||
the systemd `LimitNOFILE`). It needs neither a Chef server nor a converge — only
|
||||
the `chef` gem and stdlib ERB:
|
||||
|
||||
```
|
||||
ruby site-cookbooks/kosmos_strfry/test/strfry_sync_conf_test.rb
|
||||
```
|
||||
|
||||
`site-cookbooks/kosmos_strfry/test/member_bridge_conf_test.rb` renders
|
||||
`member_bridge.conf.erb` with the attribute shapes `member_bridge.rb` passes and
|
||||
fails if the stream group is not one-way (`dir != "down"`) or not gated by the
|
||||
LDAP-only policy (missing/wrong `pluginDown`, or a plugin path containing a
|
||||
space, which strfry would not hot-reload). Only stdlib ERB is needed:
|
||||
|
||||
```
|
||||
ruby site-cookbooks/kosmos_strfry/test/member_bridge_conf_test.rb
|
||||
```
|
||||
|
||||
## Deployment order (as performed)
|
||||
|
||||
All of the steps below have been performed; this is the order that was used.
|
||||
Keep it for rebuilding the service on another host.
|
||||
|
||||
0. **HARD PRECONDITION — akkounts `live` branch.** Before *any* converge, the
|
||||
`live` branch of `kosmos/akkounts` must contain
|
||||
`extras/strfry/submission-policy.mjs`, `extras/strfry/sync-policy.mjs` **and**
|
||||
`extras/strfry/ldap-only-policy.ts`. Chef fetches them from
|
||||
`https://gitea.kosmos.org/kosmos/akkounts/raw/branch/live/extras/strfry/…` at
|
||||
converge time; if any is missing, the `remote_file` resource fails and the
|
||||
converge aborts (with a partially configured host). Verify with:
|
||||
`curl -fsSI https://gitea.kosmos.org/kosmos/akkounts/raw/branch/live/extras/strfry/submission-policy.mjs`
|
||||
and the same for the other two files. These files are produced by WS1, not by
|
||||
this repo.
|
||||
1. **DNS.** `submit.nostr.kosmos.org` is a **CNAME to `lb.kosmos.org`** at Gandi
|
||||
(already configured). Chef does not manage DNS; the `gandi_dns` Let's Encrypt
|
||||
challenge cannot succeed without it. Verify it resolves before converging the
|
||||
proxy nodes.
|
||||
2. **Relay node.** Assign `role[strfry_submission]`, converge. Creates the
|
||||
binary (or reuses it), DB, config, policy and `strfry-submission.service`.
|
||||
The firewall allow-lists the current `role:openresty_proxy` node IPs, so the
|
||||
proxy nodes should already be registered as Chef nodes.
|
||||
3. **Proxy nodes.** Converge `role[openresty_proxy]`; this adds the
|
||||
`submit.nostr.kosmos.org` site and requests the certificate.
|
||||
4. **Enable the promotion paths.** Only after the worker + staging relay (WS2)
|
||||
are live: `role[strfry_submission]` sets `strfry.approved_sync.enabled` and
|
||||
`strfry.member_bridge.enabled` to `true` (role overrides, not the
|
||||
environment). Converge `role[strfry]`. This deploys `sync-policy.mjs`, the
|
||||
sync config, `strfry-sync.timer`, `ldap-only-policy.ts`, the member-bridge
|
||||
config and `strfry-member-bridge.service`.
|
||||
5. **Verify.**
|
||||
* `systemctl status strfry-submission` / `strfry-sync.timer` /
|
||||
`strfry-member-bridge`.
|
||||
* `curl -s -H 'Accept: application/nostr+json' https://submit.nostr.kosmos.org | jq -r .name`
|
||||
→ `Kosmos submission relay`. (Without the `Accept` header strfry serves its
|
||||
HTML info page, which `jq` cannot parse.)
|
||||
* `journalctl -u strfry-sync` shows accepted events after an approval.
|
||||
* `journalctl -u strfry-member-bridge` shows `Connected to ws://localhost:7778`
|
||||
and rejects non-member events (`pluginDown blocked event … Only members can
|
||||
publish notes on this relay`).
|
||||
* The production relay's NIP-11 and `_strfry` upstream are unchanged.
|
||||
|
||||
## Pre-go-live verification (completed)
|
||||
|
||||
* **LMDB concurrency (verified 2026-11-17 on the nuc's `:7777` mirror).** A
|
||||
`strfry sync --dir down` was run against the same LMDB that the live relay was
|
||||
serving from. Result: sync exited 0 and the relay answered 13/13 subscriptions
|
||||
(39 events) during the sync; the relay stayed active and the event count was
|
||||
unchanged. This is the same access pattern the approved-sync uses on strfry-1
|
||||
(same DB, separate `strfry sync` process), so no additional lock is needed.
|
||||
* **No rogue sync path.** Confirmed before the timer was enabled: no external
|
||||
negentropy/websocket path can produce `sourceType = "Sync"` on the production
|
||||
relay; the sync policy is fail-closed on the exact staging URL.
|
||||
|
||||
## Rollback
|
||||
|
||||
* **Sync:** set `strfry.approved_sync.enabled = false` and converge, then
|
||||
`systemctl disable --now strfry-sync.timer`. (The recipe becomes a no-op, but
|
||||
it does not stop an already-running timer.)
|
||||
* **Member bridge:** set `strfry.member_bridge.enabled = false` and converge,
|
||||
then `systemctl disable --now strfry-member-bridge`.
|
||||
* **Submission relay / proxy:** remove `kosmos_strfry_submission::nginx` from
|
||||
`role[openresty_proxy]` and `role[strfry_submission]` from the node, converge,
|
||||
then `systemctl disable --now strfry-submission`. The DB at
|
||||
`/var/lib/strfry-submission` can be deleted independently; the production
|
||||
relay and its database are untouched.
|
||||
|
||||
## Node.js caveat (checked before converging)
|
||||
|
||||
The Node write policies (`submission-policy.mjs`, `sync-policy.mjs`) are Node 24
|
||||
ESM scripts, so `role[strfry_submission]` and `role[strfry]` add a
|
||||
**role-scoped** `kosmos_nodejs.version` override to `24.22.2`. The global
|
||||
default (`14.21.3`) is deliberately **not** raised. (`ldap-only-policy.ts` is a
|
||||
Deno script and needs no Node.)
|
||||
|
||||
If either role is applied to a host that already runs other Node/JS services,
|
||||
verify they do not depend on Node 14 *before* converging:
|
||||
|
||||
* On **strfry-1**: `blossom` uses Deno (its recipe sets `DENO_DIR`), not Node;
|
||||
`substr` is the prebuilt Rust binary from the package registry. Neither
|
||||
currently installs or uses Node, so adding Node 24 is additive. Re-check if
|
||||
`substr` ever falls back to `deno task server` or if a Node-based service is
|
||||
added.
|
||||
* Any other node that gains `role[strfry_submission]` should be checked the same
|
||||
way.
|
||||
|
||||
## Out of scope
|
||||
|
||||
* Deploying/converging, DNS changes, certificate issuance, ZeroTier changes.
|
||||
* The nuc staging relay and the moderator worker (WS2; not Kosmos infra). The
|
||||
member bridge *is* covered here (`kosmos_strfry::member_bridge`).
|
||||
* The write policies themselves (WS1, `kosmos/akkounts`).
|
||||
@@ -0,0 +1,60 @@
|
||||
# Test Kitchen: open tasks
|
||||
|
||||
Status of the Test Kitchen integration suites after the migration to Cinc
|
||||
Workstation. Suites are run with Cinc Workstation's bundled `kitchen`
|
||||
(`kitchen-dokken` 2.25.0), which provisions Cinc Client via
|
||||
`provisioner: product_name: cinc`.
|
||||
|
||||
## Suites with tests
|
||||
|
||||
| Cookbook | Test | Berksfile | State |
|
||||
| --- | --- | --- | --- |
|
||||
| `kosmos-ejabberd` | `test/integration/default` | complete (path + pinned deps) | untested |
|
||||
| `kosmos_email` | `test/integration/default` | added | not green yet |
|
||||
| `kosmos_garage` | `test/integration/default` | fixed (local path deps) | untested |
|
||||
| `kosmos_rsk` | `test/integration/rskj` | complete | green (verified) |
|
||||
|
||||
## Suites without tests
|
||||
|
||||
`kosmos_liquor-cabinet` and `liquor_cabinet` declare
|
||||
`verifier.inspec_tests: test/integration/default`, but that directory does not
|
||||
exist. Either add real InSpec tests or remove the `inspec_tests` entries.
|
||||
|
||||
## Fixes applied during the migration
|
||||
|
||||
- Cinc provisioning verified: `kosmos_rsk` and `kosmos_email` both reached a
|
||||
running `cinc-client 18.2.7` inside Dokken (no Chef license prompt).
|
||||
- `kosmos_rsk` suite passes end to end (9/9) after the fixes below, confirming
|
||||
the Cinc Workstation → `kitchen-dokken` 2.25 → `product_name: cinc` pipeline.
|
||||
- `kosmos_email`: added a `Berksfile` (there was none, so declared dependencies
|
||||
like `hostname` could not resolve).
|
||||
- `kosmos_garage`: added local `path:` dependencies
|
||||
(`kosmos_openresty`, `kosmos-base`, `openresty`, `kosmos-postfix`) so Berkshelf
|
||||
no longer tries to fetch internal cookbooks from Supermarket.
|
||||
- `kosmos_rsk`: bumped the `rskj` pin from `9.0.1~<codename>` to
|
||||
`9.0.4~<codename>` (matching the current version in `ppa:rsksmart/rskj`), and
|
||||
updated the matching assertion in `test/integration/rskj/rskj_test.rb`.
|
||||
|
||||
## Remaining tasks
|
||||
|
||||
1. **`kosmos_email` is not green yet.** Even with the Berksfile, the default
|
||||
recipe pulls in a lot (`unbound`, `opendkim`, `spamassassin`, `postfix`,
|
||||
`dovecot`, `tls_cert_for` from `kosmos-base`, firewall rules). It likely needs
|
||||
a reduced/lifecycle setup before it converges in Dokken.
|
||||
2. **`kosmos_garage`** has not been run since the Berksfile fix; it uses
|
||||
Ubuntu 20.04 and needs its data bag secret.
|
||||
3. **`kosmos-ejabberd`** is untested. It has the most complete Berksfile and a
|
||||
`pre_converge` lifecycle that prepares PostgreSQL, so it is the most likely
|
||||
suite to pass — worth doing next.
|
||||
4. **Liquor suites**: add tests or drop the dangling `inspec_tests`.
|
||||
5. **Benign warning**: knife-zero double-loads `knife ssh` under knife 19,
|
||||
printing `already initialized constant Chef::Knife::Ssh::SUDO_PASSWORD_PROMPT`.
|
||||
Harmless; would need an upstream knife-zero fix to silence.
|
||||
|
||||
## Notes
|
||||
|
||||
- Suites live in `site-cookbooks/<name>/kitchen.yml`; run them with
|
||||
`kitchen test` from that directory (Cinc Workstation must be on the PATH, see
|
||||
the repository `README.md`).
|
||||
- Five cookbooks are git submodules (`blossom`, `deno`, `openresty`,
|
||||
`postgresql`, `strfry`); their suites would need changes in their own repos.
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "development",
|
||||
"description": "development environment, for example for Vagrant",
|
||||
"description": "development environment, for example for local Test Kitchen runs",
|
||||
"json_class": "Chef::Environment",
|
||||
"chef_type": "environment",
|
||||
"default_attributes": {
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
},
|
||||
"nostr": {
|
||||
"public_key": "b3e1b7c1660b7db0ecb93ec55c09e67961171a5c4e9e2602f1b47477ea61c50a",
|
||||
"relay_url": "wss://nostr.kosmos.org"
|
||||
"relay_url": "wss://nostr.kosmos.org",
|
||||
"blossom_server_url": "https://blossom.kosmos.org"
|
||||
}
|
||||
},
|
||||
"blossom": {
|
||||
|
||||
+1
-1
Submodule nodes updated: ee04075fbc...ff95561ad1.
@@ -30,6 +30,7 @@ production_run_list = %w(
|
||||
kosmos_rsk::nginx_testnet
|
||||
kosmos_rsk::nginx_mainnet
|
||||
kosmos_strfry::nginx
|
||||
kosmos_strfry_submission::nginx
|
||||
kosmos_website::default
|
||||
kosmos_website::redirects
|
||||
kosmos-akkounts::nginx
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
name "sockethub-testing"
|
||||
|
||||
default_attributes 'kosmos_redis' => {
|
||||
'requirepass' => false
|
||||
},
|
||||
'sockethub' => {
|
||||
'about' => {
|
||||
'name' => 'Sockethub Test Instance',
|
||||
'description' => '',
|
||||
'contact' => 'ops@kosmos.org',
|
||||
'links' => [],
|
||||
'showVersion' => true,
|
||||
'showUptime' => true
|
||||
}
|
||||
}
|
||||
|
||||
run_list %w(
|
||||
kosmos_redis::default
|
||||
sockethub::default
|
||||
sockethub::firewall
|
||||
)
|
||||
@@ -1,9 +1,21 @@
|
||||
name "strfry"
|
||||
|
||||
override_attributes(
|
||||
# Node 24 LTS runs the fail-closed approved-sync write policy
|
||||
# (/opt/strfry/sync-policy.mjs). Scoped to this role so the global
|
||||
# kosmos_nodejs default (14.21.3) stays untouched everywhere else.
|
||||
"kosmos_nodejs" => {
|
||||
"version" => "24.22.2"
|
||||
}
|
||||
)
|
||||
|
||||
run_list %w(
|
||||
role[ldap_client]
|
||||
kosmos-nodejs::default
|
||||
strfry::default
|
||||
kosmos_strfry::policies
|
||||
kosmos_strfry::firewall
|
||||
kosmos_strfry::substr
|
||||
kosmos_strfry::approved_sync
|
||||
kosmos_strfry::member_bridge
|
||||
)
|
||||
@@ -0,0 +1,33 @@
|
||||
name "strfry_submission"
|
||||
|
||||
override_attributes(
|
||||
# Node 24 LTS is required by the submission write policy
|
||||
# (/opt/strfry/submission-policy.mjs). This override is scoped to this role
|
||||
# only; the global kosmos_nodejs default (14.21.3) is intentionally left
|
||||
# untouched for every other node.
|
||||
"kosmos_nodejs" => {
|
||||
"version" => "24.22.2"
|
||||
},
|
||||
|
||||
# Enable the two promotion paths that feed the production relay from the
|
||||
# submission pipeline. They are toggled here (role-scoped) rather than in the
|
||||
# production environment config, so the switches travel with this feature's
|
||||
# roles. The recipes themselves live in role[strfry] (the relay node runs both
|
||||
# roles).
|
||||
"strfry" => {
|
||||
"approved_sync" => {
|
||||
"enabled" => true
|
||||
},
|
||||
"member_bridge" => {
|
||||
"enabled" => true
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
run_list %w(
|
||||
role[base]
|
||||
role[kvm_guest]
|
||||
kosmos-nodejs::default
|
||||
kosmos_strfry_submission::default
|
||||
kosmos_strfry_submission::firewall
|
||||
)
|
||||
Executable
+85
@@ -0,0 +1,85 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Prepare a node for Cinc Workstation management so that a plain
|
||||
# `knife zero converge` works afterwards.
|
||||
#
|
||||
# Usage: scripts/knife/migrate_node_to_cinc.sh NODE_NAME
|
||||
#
|
||||
# Idempotent and safe to re-run. Run from the chef repo (uses .cinc/config.rb).
|
||||
#
|
||||
# What it does on the node (as root, over knife's own SSH connection):
|
||||
# 1. installs the current stable Cinc Client if the node still runs Chef
|
||||
# Infra Client (omnitruck resolves the right build for the platform)
|
||||
# 2. makes /etc/cinc resolve to the existing knife-zero config in /etc/chef
|
||||
# 3. drops the deprecated attribute whitelist/blacklist lines from client.rb
|
||||
# 4. pre-seeds /etc/cinc/client.d/attributes.rb (the allowed_* lists) so the
|
||||
# first converge does not filter node attributes
|
||||
# 5. best-effort removes the leftover upstream chef package
|
||||
set -euo pipefail
|
||||
|
||||
node="${1:?usage: $0 NODE_NAME}"
|
||||
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
attributes_file="$repo_root/site-cookbooks/kosmos-base/files/default/chef_attributes.rb"
|
||||
node_file="$repo_root/nodes/$node.json"
|
||||
|
||||
[[ -f "$node_file" ]] || { echo "error: no node file at $node_file" >&2; exit 1; }
|
||||
[[ -f "$attributes_file" ]] || { echo "error: no attributes file at $attributes_file" >&2; exit 1; }
|
||||
|
||||
# host + port, same convention as scripts/knife/converge_all.sh
|
||||
read -r host vm_host < <(python3 -c '
|
||||
import json, sys
|
||||
d = json.load(open(sys.argv[1]))
|
||||
n = d.get("normal", {})
|
||||
print(n.get("knife_zero", {}).get("host", ""), n.get("vm_host", ""))
|
||||
' "$node_file")
|
||||
[[ -n "$host" ]] || { echo "error: $node has no knife_zero.host" >&2; exit 1; }
|
||||
port=22; [[ -n "$vm_host" ]] || port=2222
|
||||
|
||||
attr_b64="$(base64 -w0 "$attributes_file")"
|
||||
|
||||
remote="$(mktemp)"; trap 'rm -f "$remote"' EXIT
|
||||
cat >"$remote" <<EOF
|
||||
set -euo pipefail
|
||||
|
||||
# 1. Cinc Client (Chef -> Cinc migration, or fresh).
|
||||
# Install the current stable release for this platform. omnitruck resolves the
|
||||
# right build per OS (so 20.04 and 22.04+ each get their latest supported
|
||||
# version), and passing -v also suppresses the "without a version pin" warning.
|
||||
if ! command -v cinc-client >/dev/null 2>&1 && [ ! -x /opt/cinc/bin/cinc-client ]; then
|
||||
echo ">> installing the current stable Cinc Client"
|
||||
curl -sL https://omnitruck.cinc.sh/install.sh | bash -s -- -v latest
|
||||
fi
|
||||
|
||||
# 2. Point /etc/cinc at the existing knife-zero config in /etc/chef
|
||||
if [ -L /etc/cinc ]; then
|
||||
echo ">> /etc/cinc already a symlink"
|
||||
elif [ -d /etc/cinc ] && [ -d /etc/chef ]; then
|
||||
echo ">> replacing package /etc/cinc with symlink to /etc/chef"
|
||||
rm -rf /etc/cinc && ln -s /etc/chef /etc/cinc
|
||||
elif [ ! -e /etc/cinc ] && [ -d /etc/chef ]; then
|
||||
echo ">> linking /etc/cinc -> /etc/chef"
|
||||
ln -s /etc/chef /etc/cinc
|
||||
fi
|
||||
|
||||
# 3. Drop deprecated attribute lists so they don't shadow the new ones
|
||||
sed -i -E '/^[[:space:]]*(automatic|default|normal|override)_attribute_(white|black)list/d' /etc/cinc/client.rb 2>/dev/null || true
|
||||
|
||||
# 4. Pre-seed the allowlist from the repo (source of truth), before first converge
|
||||
mkdir -p /etc/cinc/client.d
|
||||
echo '$attr_b64' | base64 -d > /etc/cinc/client.d/attributes.rb
|
||||
echo ">> wrote /etc/cinc/client.d/attributes.rb"
|
||||
|
||||
# 5. Best-effort: drop the leftover upstream chef package
|
||||
if command -v dpkg >/dev/null 2>&1 && dpkg -l chef 2>/dev/null | grep -q '^ii'; then
|
||||
echo ">> removing the upstream chef package"
|
||||
apt-get remove -y chef >/dev/null
|
||||
fi
|
||||
|
||||
echo ">> $node is ready. Converge with:"
|
||||
echo ">> knife zero converge -a knife_zero.host -p$port name:$node"
|
||||
EOF
|
||||
|
||||
# ship the script (base64) and run it as root over knife's own connection
|
||||
b64="$(base64 -w0 "$remote")"
|
||||
knife ssh -a knife_zero.host -p"$port" "name:$node" "echo $b64 | base64 -d | sudo bash"
|
||||
@@ -9,14 +9,14 @@ fi
|
||||
|
||||
old_primary_hostname=$1
|
||||
new_primary_hostname=$2
|
||||
new_primary_ip=`bundle exec knife node show $new_primary_hostname -a knife_zero.host | grep -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}" -o`
|
||||
new_primary_ip=`knife node show $new_primary_hostname -a knife_zero.host | grep -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}" -o`
|
||||
|
||||
echo "Switching primary to $new_primary_hostname ($new_primary_ip)"
|
||||
bundle exec knife ssh name:$new_primary_hostname -a knife_zero.host "sudo su - postgres -c '/usr/lib/postgresql/12/bin/pg_ctl promote -D /var/lib/postgresql/12/main'"
|
||||
knife ssh name:$new_primary_hostname -a knife_zero.host "sudo su - postgres -c '/usr/lib/postgresql/12/bin/pg_ctl promote -D /var/lib/postgresql/12/main'"
|
||||
echo "Stopping postgresql on $old_primary_hostname"
|
||||
bundle exec knife ssh name:$old_primary_hostname -a knife_zero.host "sudo systemctl stop postgresql@12-main.service"
|
||||
knife ssh name:$old_primary_hostname -a knife_zero.host "sudo systemctl stop postgresql@12-main.service"
|
||||
echo "Replacing pg.kosmos.local host entries with $new_primary_ip"
|
||||
bundle exec knife ssh roles:postgresql_client -a knife_zero.host "sudo sed -r \"s/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\s(pg.kosmos.local)/$new_primary_ip\t\1/\" -i /etc/hosts"
|
||||
knife ssh roles:postgresql_client -a knife_zero.host "sudo sed -r \"s/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\s(pg.kosmos.local)/$new_primary_ip\t\1/\" -i /etc/hosts"
|
||||
|
||||
# TODO
|
||||
# 1. Change roles in node configs
|
||||
|
||||
+1
-1
Submodule site-cookbooks/deno updated: 3795c9e672...c78bc66912.
@@ -8,8 +8,8 @@ upstream _<%= @upstream_name %> {
|
||||
<% if File.exist?(@ssl_cert) && File.exist?(@ssl_key) -%>
|
||||
server {
|
||||
server_name <%= @server_name %>;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
|
||||
ssl_certificate <%= @ssl_cert %>;
|
||||
ssl_certificate_key <%= @ssl_key %>;
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# kosmos-akkounts CHANGELOG
|
||||
|
||||
# 0.5.0
|
||||
|
||||
- Upgrade Ruby to 3.3.14 for the Regexp and String case conversion security
|
||||
fixes (RCE-capable, see https://www.ruby-lang.org/en/news/2026/11/18/multiple-vulnerabilities-in-regexp-and-string/).
|
||||
- Disable Sentry while its host is down: with no DSN in the app environment,
|
||||
the app skips Sentry.init and makes no requests to it.
|
||||
- Pass the Blossom server URL to the app environment.
|
||||
|
||||
# 0.4.0
|
||||
|
||||
- Add Redis password support to the remoteStorage Redis URL.
|
||||
|
||||
@@ -23,6 +23,7 @@ node.default['akkounts']['lndhub']['postgres_db'] = 'lndhub'
|
||||
|
||||
node.default['akkounts']['nostr']['public_key'] = nil
|
||||
node.default['akkounts']['nostr']['relay_url'] = nil
|
||||
node.default['akkounts']['nostr']['blossom_server_url'] = nil
|
||||
|
||||
node.default['akkounts']['s3_enabled'] = true
|
||||
node.default['akkounts']['s3_endpoint'] = "https://s3.kosmos.org"
|
||||
|
||||
@@ -4,7 +4,7 @@ maintainer_email 'mail@kosmos.org'
|
||||
license 'MIT'
|
||||
description 'Installs/configures kosmos-akkounts'
|
||||
long_description 'Installs/configures kosmos-akkounts'
|
||||
version '0.4.0'
|
||||
version '0.5.0'
|
||||
chef_version '>= 18.0'
|
||||
|
||||
depends 'kosmos_openresty'
|
||||
|
||||
@@ -46,12 +46,12 @@ link "/usr/local/bin/bun" do
|
||||
to "/usr/local/bun/#{bun_version}/bin/bun"
|
||||
end
|
||||
|
||||
ruby_version = "3.3.12"
|
||||
ruby_version = "3.3.14"
|
||||
ruby_path = "/opt/ruby_build/builds/#{ruby_version}"
|
||||
bundle_path = "#{ruby_path}/bin/bundle"
|
||||
rails_env = node.chef_environment == "development" ? "development" : "production"
|
||||
|
||||
ruby_build_install 'v20260701'
|
||||
ruby_build_install 'v20261119'
|
||||
ruby_build_definition ruby_version do
|
||||
prefix_path ruby_path
|
||||
end
|
||||
@@ -100,7 +100,10 @@ env[:smtp] = {
|
||||
enable_starttls: node['akkounts']['smtp']['enable_starttls']
|
||||
}
|
||||
|
||||
env[:sentry_dsn] = credentials["sentry_dsn"]
|
||||
# Sentry's host (sentry.kosmos.local / 10.1.1.132) is down as of 2026-11-21.
|
||||
# Leaving SENTRY_DSN unset makes config/initializers/sentry.rb skip Sentry.init,
|
||||
# so the app makes no requests to it. Uncomment once Sentry is back.
|
||||
# env[:sentry_dsn] = credentials["sentry_dsn"]
|
||||
|
||||
if webhooks_allowed_ips.length > 0
|
||||
env[:webhooks_allowed_ips] = webhooks_allowed_ips
|
||||
@@ -201,6 +204,7 @@ env[:mediawiki_public_url] = node['mediawiki']['url']
|
||||
env[:nostr_private_key] = credentials['nostr_private_key']
|
||||
env[:nostr_public_key] = node['akkounts']['nostr']['public_key']
|
||||
env[:nostr_relay_url] = node['akkounts']['nostr']['relay_url']
|
||||
env[:nostr_blossom_server_url] = node['akkounts']['nostr']['blossom_server_url']
|
||||
|
||||
#
|
||||
# remoteStorage / Liquor Cabinet
|
||||
@@ -245,12 +249,27 @@ systemd_unit "akkounts.service" do
|
||||
Type: "simple",
|
||||
User: deploy_user,
|
||||
WorkingDirectory: deploy_path,
|
||||
Environment: "RAILS_ENV=#{rails_env} SOLID_QUEUE_IN_PUMA=true",
|
||||
# Solid Queue worker sizing (see config/queue.yml in the app):
|
||||
# * JOB_CONCURRENCY scales the `default,nostr` group's processes; each
|
||||
# extra process costs ~60-90 MB.
|
||||
# * NOSTR_CONNECT_THREADS sizes the `nostr_connect` listener pool. Those
|
||||
# jobs block a thread for up to 5 min on relay websockets, so they get
|
||||
# many cheap threads instead of processes.
|
||||
# * NOSTR_RPC_THREADS sizes the separate signing pool so sign events
|
||||
# never queue behind the long-running listeners.
|
||||
# * DB_POOL must be >= the largest thread count, or worker threads hit
|
||||
# ActiveRecord::ConnectionTimeoutError under load.
|
||||
Environment: "RAILS_ENV=#{rails_env} SOLID_QUEUE_IN_PUMA=true " \
|
||||
"JOB_CONCURRENCY=6 NOSTR_CONNECT_THREADS=24 " \
|
||||
"NOSTR_RPC_THREADS=4 DB_POOL=24",
|
||||
ExecStart: "#{bundle_path} exec puma -C config/puma.rb --pidfile #{deploy_path}/tmp/puma.pid",
|
||||
ExecReload: "#{bundle_path} exec pumactl -F config/puma.rb --pidfile #{deploy_path}/tmp/puma.pid phased-restart",
|
||||
PIDFile: "#{deploy_path}/tmp/puma.pid",
|
||||
TimeoutSec: "30",
|
||||
Restart: "always",
|
||||
# Guard against a runaway worker triggering the host-wide OOM killer.
|
||||
MemoryHigh: "3G",
|
||||
MemoryMax: "3500M",
|
||||
},
|
||||
Install: {
|
||||
WantedBy: "multi-user.target"
|
||||
@@ -259,6 +278,10 @@ systemd_unit "akkounts.service" do
|
||||
verify false
|
||||
triggers_reload true
|
||||
action [:create, :enable]
|
||||
# The unit body carries JOB_CONCURRENCY (and the memory guards), so a change
|
||||
# here must restart the service to take effect. Nothing else notifies it
|
||||
# unless the git checkout / .env also change.
|
||||
notifies :restart, "service[#{app_name}]", :delayed
|
||||
end
|
||||
|
||||
deploy_env = {
|
||||
|
||||
@@ -10,8 +10,8 @@ proxy_cache_path <%= node[:openresty][:cache_dir] %>/akkounts levels=1:2
|
||||
max_size=1g inactive=120m use_temp_path=off;
|
||||
|
||||
server {
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
server_name <%= @domain %>;
|
||||
|
||||
if ($host != $server_name) {
|
||||
|
||||
@@ -6,8 +6,8 @@ upstream _akkounts_api {
|
||||
}
|
||||
|
||||
server {
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
server_name <%= @domain %>;
|
||||
|
||||
ssl_certificate <%= @ssl_cert %>;
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
#
|
||||
# Cookbook:: kosmos-base
|
||||
# Recipe:: cve_2026_98432
|
||||
#
|
||||
# Interim mitigations for CVE-2026-98432: a use-after-free in the Linux IPv4
|
||||
# TCP option handling (inet_opt/ireq_opt are freed with a plain kfree()) that
|
||||
# is reachable by sending a TCP SYN carrying IP options. No fixed kernel has
|
||||
# been released for Ubuntu yet, so until every host runs a patched kernel we:
|
||||
#
|
||||
# 1. drop inbound IPv4 TCP segments that carry IP options (no legitimate
|
||||
# traffic uses them), and
|
||||
# 2. disable Multipath TCP where the running kernel supports it, so that Go
|
||||
# programs built with Go >= 1.24 (e.g. node_exporter) stop opening MPTCP
|
||||
# listeners - the precondition of the published exploit.
|
||||
#
|
||||
# This recipe (and the matching change in kosmos_prometheus::node_exporter) can
|
||||
# be removed once all hosts run a kernel containing the fix.
|
||||
#
|
||||
|
||||
# --- 1. Drop inbound IPv4 TCP segments that carry IP options ----------------
|
||||
#
|
||||
# ufw rebuilds its ruleset from /etc/ufw/before.rules on every start/reload, so
|
||||
# the restriction has to live in that file to survive. The u32 expression
|
||||
# `0&0x0F000000=0x05000000` matches a segment whose IP header length (IHL) is
|
||||
# 5, i.e. one *without* IP options; negating it drops any segment that carries
|
||||
# them. Drops are logged (rate limited) so probing is visible.
|
||||
before_rules = "/etc/ufw/before.rules"
|
||||
cve_marker = "CVE-2026-98432"
|
||||
ipopts_match = '-p tcp -m u32 ! --u32 "0&0x0F000000=0x05000000"'
|
||||
|
||||
ruby_block "ufw: drop IPv4 TCP segments with IP options (#{cve_marker})" do
|
||||
block do
|
||||
editor = Chef::Util::FileEdit.new(before_rules)
|
||||
editor.search_file_delete_line(/#{cve_marker}/)
|
||||
editor.insert_line_after_match(
|
||||
/^# End required lines$/,
|
||||
"# #{cve_marker}: drop IPv4 TCP segments carrying IP options\n" \
|
||||
"-A ufw-before-input -m comment --comment \"#{cve_marker}\" #{ipopts_match} " \
|
||||
"-m limit --limit 5/min -j LOG --log-prefix \"[#{cve_marker}] ipopts \" --log-level 4\n" \
|
||||
"-A ufw-before-input -m comment --comment \"#{cve_marker}\" #{ipopts_match} -j DROP"
|
||||
)
|
||||
editor.write_file
|
||||
|
||||
raise "#{cve_marker}: failed to add the ip-options drop rule to #{before_rules}" \
|
||||
unless ::File.read(before_rules).include?(cve_marker)
|
||||
end
|
||||
not_if { ::File.exist?(before_rules) && ::File.read(before_rules).include?(cve_marker) }
|
||||
notifies :run, "execute[reload ufw]"
|
||||
end
|
||||
|
||||
execute "reload ufw" do
|
||||
command "ufw reload"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# --- 2. Disable Multipath TCP where the kernel supports it ------------------
|
||||
#
|
||||
# MPTCP is in-tree since Linux 5.6; the /proc entry only exists when it is
|
||||
# available, so the compile-time guard keeps older (5.4) hosts from writing a
|
||||
# sysctl for a key their kernel does not know. Nothing in our stack needs MPTCP.
|
||||
#
|
||||
# Not using the core `sysctl` resource here: its reload runs `sysctl -p`, which
|
||||
# reads /etc/sysctl.conf - a file that does not exist on Ubuntu 26.04, making
|
||||
# the resource fail. Writing the drop-in and applying the value explicitly works
|
||||
# on every release we run.
|
||||
if ::File.exist?("/proc/sys/net/mptcp/enabled")
|
||||
file "/etc/sysctl.d/99-chef-net.mptcp.enabled.conf" do
|
||||
content "net.mptcp.enabled = 0\n"
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0644"
|
||||
end
|
||||
|
||||
execute "disable multipath TCP (net.mptcp.enabled=0)" do
|
||||
command "sysctl -w net.mptcp.enabled=0"
|
||||
not_if { ::File.read("/proc/sys/net/mptcp/enabled").strip == "0" }
|
||||
end
|
||||
end
|
||||
@@ -77,6 +77,8 @@ unless node.chef_environment == "development"
|
||||
|
||||
include_recipe "kosmos-base::firewall"
|
||||
|
||||
include_recipe "kosmos-base::cve_2026_98432"
|
||||
|
||||
include_recipe "kosmos-base::tmux"
|
||||
|
||||
include_recipe "kosmos-postfix"
|
||||
|
||||
@@ -88,7 +88,7 @@ node.default['lndhub-go']['branding'] = {
|
||||
}
|
||||
|
||||
node.default['nbxplorer']['repo'] = 'https://github.com/dgarage/NBXplorer'
|
||||
node.default['nbxplorer']['revision'] = 'v2.6.10'
|
||||
node.default['nbxplorer']['revision'] = 'v2.6.21'
|
||||
node.default['nbxplorer']['source_dir'] = '/opt/nbxplorer'
|
||||
node.default['nbxplorer']['config_path'] = "/home/#{node['bitcoin']['username']}/.nbxplorer/Main/settings.config"
|
||||
node.default['nbxplorer']['port'] = '24445'
|
||||
@@ -96,7 +96,7 @@ node.default['nbxplorer']['postgres']['database'] = 'nbxplorer'
|
||||
node.default['nbxplorer']['postgres']['user'] = 'nbxplorer'
|
||||
|
||||
node.default['btcpay']['repo'] = 'https://github.com/btcpayserver/btcpayserver'
|
||||
node.default['btcpay']['revision'] = 'v2.4.3'
|
||||
node.default['btcpay']['revision'] = 'v2.4.7'
|
||||
node.default['btcpay']['source_dir'] = '/opt/btcpay'
|
||||
node.default['btcpay']['config_path'] = "/home/#{node['bitcoin']['username']}/.btcpayserver/Main/settings.config"
|
||||
node.default['btcpay']['log_path'] = "/home/#{node['bitcoin']['username']}/.btcpayserver/debug.log"
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
---
|
||||
driver:
|
||||
name: vagrant
|
||||
|
||||
## The forwarded_port port feature lets you connect to ports on the VM guest via
|
||||
## localhost on the host.
|
||||
## see also: https://www.vagrantup.com/docs/networking/forwarded_ports.html
|
||||
|
||||
# network:
|
||||
# - ["forwarded_port", {guest: 80, host: 8080}]
|
||||
|
||||
provisioner:
|
||||
name: chef_zero
|
||||
|
||||
## product_name and product_version specifies a specific Chef product and version to install.
|
||||
## see the Chef documentation for more details: https://docs.chef.io/config_yml_kitchen.html
|
||||
# product_name: chef
|
||||
# product_version: 15
|
||||
|
||||
verifier:
|
||||
name: inspec
|
||||
|
||||
platforms:
|
||||
- name: ubuntu-18.04
|
||||
- name: centos-7
|
||||
|
||||
suites:
|
||||
- name: default
|
||||
verifier:
|
||||
inspec_tests:
|
||||
- test/integration/default
|
||||
attributes:
|
||||
@@ -48,8 +48,8 @@ proxy_set_header Proxy "";
|
||||
server {
|
||||
client_max_body_size 100M;
|
||||
server_name <%= @server_name %>;
|
||||
listen 443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
listen 443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
|
||||
access_log <%= node[:nginx][:log_dir] %>/btcpayserver.access.log json;
|
||||
error_log <%= node[:nginx][:log_dir] %>/btcpayserver.error.log warn;
|
||||
|
||||
@@ -6,8 +6,8 @@ upstream _lndhub {
|
||||
}
|
||||
|
||||
server {
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
server_name <%= @server_name %>;
|
||||
|
||||
add_header Strict-Transport-Security "max-age=15768000";
|
||||
|
||||
@@ -48,8 +48,8 @@ server {
|
||||
client_max_body_size 100M;
|
||||
server_name <%= @server_name %>;
|
||||
<% if File.exist?(@ssl_cert) && File.exist?(@ssl_key) -%>
|
||||
listen 443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
listen 443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
<% else -%>
|
||||
listen 80;
|
||||
<% end -%>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
---
|
||||
driver:
|
||||
name: dokken
|
||||
chef_version: 18.2.7
|
||||
pull_platform_image: false
|
||||
pull_chef_image: false
|
||||
memory_limit: 2147483648 # 2GB
|
||||
@@ -14,6 +13,7 @@ transport:
|
||||
|
||||
provisioner:
|
||||
name: dokken
|
||||
product_name: cinc
|
||||
client_rb:
|
||||
# the ejabberd package starts its service as ejabberd@localhost during
|
||||
# installation; keep the chef node name in sync so ERLANG_NODE matches
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
# Generated by Chef
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
listen 443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
server_name <%= @server_name %>;
|
||||
|
||||
ssl_certificate <%= @ssl_cert %>;
|
||||
|
||||
@@ -6,8 +6,8 @@ upstream _express_<%= @server_name.gsub(".", "_") %> {
|
||||
}
|
||||
|
||||
server {
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
server_name <%= @server_name %>;
|
||||
|
||||
add_header Strict-Transport-Security "max-age=15768000";
|
||||
|
||||
@@ -11,8 +11,8 @@ upstream _ipfs_api {
|
||||
|
||||
server {
|
||||
server_name <%= @server_name %>;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
|
||||
access_log /var/log/nginx/<%= @server_name %>.access.log;
|
||||
error_log /var/log/nginx/<%= @server_name %>.error.log;
|
||||
@@ -27,7 +27,7 @@ server {
|
||||
|
||||
server {
|
||||
<% if File.exist?(@ssl_cert) && File.exist?(@ssl_key) -%>
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %><%= @ipfs_external_api_port %> ssl http2;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %><%= @ipfs_external_api_port %> ssl;
|
||||
<% else -%>
|
||||
listen <%= @ipfs_external_api_port %>;
|
||||
<% end -%>
|
||||
|
||||
@@ -4,7 +4,7 @@ maintainer_email 'mail@kosmos.org'
|
||||
license 'MIT'
|
||||
description 'Installs/Configures Mastodon'
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version '0.2.1'
|
||||
version '0.2.2'
|
||||
|
||||
depends 'elasticsearch'
|
||||
depends 'firewall'
|
||||
|
||||
@@ -20,8 +20,8 @@ proxy_cache_path /var/cache/nginx/mastodon levels=1:2
|
||||
max_size=1g inactive=120m use_temp_path=off;
|
||||
|
||||
server {
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
server_name <%= @server_name %>;
|
||||
include <%= @shared_config_path %>;
|
||||
|
||||
@@ -47,7 +47,7 @@ server {
|
||||
include <%= @shared_config_path %>;
|
||||
}
|
||||
server {
|
||||
listen 127.0.0.1:443 ssl http2;
|
||||
listen 127.0.0.1:443 ssl;
|
||||
server_name mastodon.<%= @onion_address %>;
|
||||
include <%= @shared_config_path %>;
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
# Generated by Chef
|
||||
|
||||
server {
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
server_name <%= @domain %>;
|
||||
|
||||
root /var/www/<%= @domain %>/site;
|
||||
|
||||
@@ -8,8 +8,8 @@ proxy_cache_path <%= node['openresty']['cache_dir'] %>/blossom
|
||||
|
||||
server {
|
||||
server_name <%= @domain %>;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
|
||||
access_log "/var/log/nginx/<%= @domain %>.access.log" json;
|
||||
error_log "/var/log/nginx/<%= @domain %>.error.log";
|
||||
|
||||
@@ -8,8 +8,8 @@ upstream _discourse {
|
||||
<% if File.exist?(@ssl_cert) && File.exist?(@ssl_key) -%>
|
||||
server {
|
||||
server_name <%= @server_name %>;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
|
||||
ssl_certificate <%= @ssl_cert %>;
|
||||
ssl_certificate_key <%= @ssl_key %>;
|
||||
|
||||
@@ -7,8 +7,8 @@ upstream _drone {
|
||||
|
||||
server {
|
||||
server_name <%= @server_name %>;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
|
||||
ssl_certificate <%= @ssl_cert %>;
|
||||
ssl_certificate_key <%= @ssl_key %>;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
source 'https://supermarket.chef.io'
|
||||
|
||||
# community cookbooks pinned to the versions vendored for production (see the
|
||||
# root Berksfile.lock), so the integration suite exercises the same cookbook set
|
||||
cookbook 'firewall', '= 6.2.16'
|
||||
cookbook 'hostname', '= 0.4.2'
|
||||
cookbook 'unbound', '~> 3.0.2'
|
||||
cookbook 'postfix',
|
||||
git: 'https://gitea.kosmos.org/kosmos/postfix-cookbook.git',
|
||||
ref: 'bugfix/sasl_attributes'
|
||||
|
||||
# local cookbooks
|
||||
cookbook 'kosmos-base', path: '../kosmos-base'
|
||||
cookbook 'kosmos-postfix', path: '../kosmos-postfix'
|
||||
|
||||
metadata
|
||||
@@ -1,7 +1,6 @@
|
||||
---
|
||||
driver:
|
||||
name: dokken
|
||||
chef_version: 18.2.7
|
||||
pull_platform_image: false
|
||||
pull_chef_image: false
|
||||
memory_limit: 2147483648 # 2GB
|
||||
@@ -25,10 +24,8 @@ provisioner:
|
||||
# always_update_cookbooks: <%= !ENV['CI'] %>
|
||||
# always_update_cookbooks: false
|
||||
|
||||
## product_name and product_version specifies a specific Chef product and version to install.
|
||||
## see the Chef documentation for more details: https://docs.chef.io/workstation/config_yml_kitchen/
|
||||
# product_name: chef
|
||||
# product_version: 16
|
||||
# install Cinc Client instead of the license-gated Chef Infra Client
|
||||
product_name: cinc
|
||||
|
||||
verifier:
|
||||
name: inspec
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
source 'https://supermarket.chef.io'
|
||||
|
||||
# local cookbooks
|
||||
cookbook 'kosmos_openresty', path: '../kosmos_openresty'
|
||||
cookbook 'kosmos-base', path: '../kosmos-base'
|
||||
cookbook 'openresty', path: '../openresty'
|
||||
cookbook 'kosmos-postfix', path: '../kosmos-postfix'
|
||||
|
||||
metadata
|
||||
@@ -10,6 +10,7 @@ transport:
|
||||
|
||||
provisioner:
|
||||
name: dokken
|
||||
product_name: cinc
|
||||
clean_dokken_sandbox: false
|
||||
client_rb:
|
||||
environment: testing
|
||||
|
||||
@@ -3,8 +3,8 @@ upstream garage_s3 {
|
||||
}
|
||||
|
||||
server {
|
||||
listen <%= "#{node[:openresty][:listen_ip]}:" if node[:openresty][:listen_ip] %>443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
listen <%= "#{node[:openresty][:listen_ip]}:" if node[:openresty][:listen_ip] %>443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
|
||||
ssl_certificate <%= @ssl_cert %>;
|
||||
ssl_certificate_key <%= @ssl_key %>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
server {
|
||||
listen <%= "#{node[:openresty][:listen_ip]}:" if node[:openresty][:listen_ip] %>443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
listen <%= "#{node[:openresty][:listen_ip]}:" if node[:openresty][:listen_ip] %>443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
|
||||
server_name <%= @server_name %>;
|
||||
|
||||
|
||||
@@ -2,6 +2,91 @@
|
||||
|
||||
This file is used to list changes made in each version of the kosmos_gitea cookbook.
|
||||
|
||||
# 0.3.10
|
||||
|
||||
- Upgrade Gitea from 28.3.0 to 28.4.0 (maintenance/security release, no `app.ini`
|
||||
changes).
|
||||
- Upgrade the Gitea Actions runner from 5.4.0 to 6.1.0. Breaking: 6.0.0 removed
|
||||
the `builtin:checkout` action, which we map to `actions/checkout@v6` via
|
||||
`runner.action_replacements`. 6.1.0 runs JavaScript actions on a Node.js 24
|
||||
that the runner downloads and mounts into jobs.
|
||||
|
||||
# 0.3.9
|
||||
|
||||
- Move the bot-blocking configuration out of the cookbook and into the
|
||||
encrypted `credentials/gitea` data bag (new `bot_filter` key), so the
|
||||
rate-limited crawler names, the hard-banned user agents and the denied
|
||||
networks are no longer published in the public repository and can be changed
|
||||
by editing the data bag instead of the cookbook.
|
||||
- `rate_limits.conf` and `robots.txt` are now rendered from the data bag
|
||||
(`rate_limits.conf.erb`, `robots.txt.erb`). The rate values and the
|
||||
expensive-route / robots route patterns stay static in the templates.
|
||||
- `bot_filter` schema: `limit` (list of `{match, key}`), `deny_user_agents`
|
||||
(list of user-agent patterns) and `deny_networks` (list of CIDRs).
|
||||
|
||||
# 0.3.8
|
||||
|
||||
- Broaden the Gitea edge bot controls on the openresty proxy:
|
||||
- Rate-limit several additional AI crawlers and tighten the `bots` zone from
|
||||
240r/m to 60r/m per IP. The heavy crawlers average under 1.5r/s, so the old
|
||||
rate never engaged and the listed crawlers were effectively unthrottled.
|
||||
- Hard-block a datacenter scraper network that spoofs browser User-Agents, so
|
||||
it cannot be matched by UA, and enumerates historical commit pages.
|
||||
- Disallow `/*/src/commit/` and `/*/commits/commit/` in robots.txt. These
|
||||
combinatorial commit-browsing routes were ~56% of the traffic to Gitea.
|
||||
|
||||
# 0.3.7
|
||||
|
||||
- Upgrade the Gitea Actions runner from 5.2.4 to 5.4.0. No `config.yaml` changes
|
||||
were required.
|
||||
- 5.3.0 scopes cache entries by ref, like GitHub: a job restores from its own
|
||||
ref, then the base branch, then the repository's default branch, and writes
|
||||
only to its own ref. Existing (unscoped) caches therefore start out cold once
|
||||
after this upgrade. 5.3.0 also adds `GITEA_*` aliases for the built-in
|
||||
`GITHUB_*` environment variables and updates dependencies for
|
||||
CVE-2026-78661.
|
||||
- 5.4.0 adds Windows and FreeBSD support, `runner.ca_file` for trusting a
|
||||
private CA, and `container.volumes`; it signs release checksums and fixes
|
||||
large cache uploads, concurrent Dockerfile actions, and git-lfs checkouts on
|
||||
git-lfs versions before 3.8.0.
|
||||
- This re-establishes 5.4.0 on gitea-2, which had been downgraded back to 5.2.2
|
||||
by a converge from a branch that predated the previous upgrade. Gitea reports
|
||||
the runner version sent on each heartbeat, so the runners update on restart.
|
||||
|
||||
# 0.3.6
|
||||
|
||||
- Stop pinning job containers to one shared Docker network. `container.network`
|
||||
is empty again, so the runner auto-creates an isolated bridge network per job:
|
||||
concurrent jobs keep service-container DNS (e.g. `redis`) but can no longer
|
||||
resolve each other's service containers, fixing intermittent cross-job CI
|
||||
failures. `cache.host` is auto-detected, and the cache firewall rule now allows
|
||||
Docker's default address pool (`172.16.0.0/12`).
|
||||
- Remove the now-unused `gitea-actions` network on converge (once idle).
|
||||
|
||||
# 0.3.5
|
||||
|
||||
- Upgrade Gitea from 28.1.0 to 28.3.0, skipping 28.2.0. Both are maintenance
|
||||
releases with no breaking changes and no `app.ini` changes; no configuration
|
||||
updates were required.
|
||||
- Security fixes included: token scope enforcement on many API and web routes
|
||||
(public-only tokens could read private data and, for admins, create
|
||||
administrators), OAuth2 `ACCOUNT_LINKING = auto` account takeover, review
|
||||
triggered Actions workflows running with repository secrets, stored XSS via
|
||||
Actions artifact `Content-Encoding`, SSH certificate principal confusion,
|
||||
OpenID association CSRF, and several private-data leaks in feeds, profiles,
|
||||
project boards and issue timelines.
|
||||
- Behavior changes to be aware of (no cookbook change): `git maintenance` now
|
||||
defaults to the `gc` strategy; profile pages treat token requests as
|
||||
anonymous and user/org RSS/Atom feeds require `read:user` /
|
||||
`read:organization`; the API rejects changes to issues, labels, milestones
|
||||
and releases of archived repositories; review-triggered workflows run on the
|
||||
pull request head; the `gitea-vscode` OAuth2 application is pre-registered;
|
||||
email address validation is relaxed to what Go's `mail.ParseAddress` accepts.
|
||||
- Upgrade the Gitea Actions runner from 5.2.2 to 5.2.4. No `config.yaml`
|
||||
changes were required. 5.2.4 fixes the v4 artifact API in `exec` mode so
|
||||
`upload-artifact` v4 and later work, and 5.2.3 fixes the action header group,
|
||||
dry runs touching the Docker daemon, and damaged shared action cache trees.
|
||||
|
||||
# 0.3.4
|
||||
|
||||
- Upgrade the Gitea Actions runner from 5.0.0 to 5.2.2. No `config.yaml` changes
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
node.default["gitea"]["version"] = "28.1.0"
|
||||
node.default["gitea"]["checksum"] = "ea93cfa4a300564ac457d3903469fea49ec5a4da37d0cebaa435f8e329ea64d0"
|
||||
node.default["gitea"]["version"] = "28.4.0"
|
||||
node.default["gitea"]["checksum"] = "154e775bd6bb589fc14cd93a689d8fbc64090aaa3ec537f0e3af298b13c6d386"
|
||||
node.default["gitea"]["repo"] = nil
|
||||
node.default["gitea"]["revision"] = nil
|
||||
node.default["gitea"]["working_directory"] = "/var/lib/gitea"
|
||||
@@ -24,19 +24,31 @@ node.default["gitea"]["config"] = {
|
||||
}
|
||||
}
|
||||
|
||||
node.default["gitea"]["runner"]["version"] = "5.2.2"
|
||||
node.default["gitea"]["runner"]["checksum"] = "5a2639fd2a57feeba29a9b1fb0e941489f092a4fa681c7c333c0372731248b63"
|
||||
node.default["gitea"]["runner"]["version"] = "6.1.0"
|
||||
node.default["gitea"]["runner"]["checksum"] = "c5100ff3c201163080fedd66153c0d80c2941e835ded2df627444ed78a9167d7"
|
||||
node.default["gitea"]["runner"]["cache_base_port"] = 8088
|
||||
node.default["gitea"]["runner"]["config"] = {
|
||||
"runner" => {
|
||||
"capacity" => 2
|
||||
"capacity" => 2,
|
||||
# Runner 6.0 removed the builtin:checkout action. Rewrite any workflow that
|
||||
# still uses it so it keeps working; actions/checkout is the replacement
|
||||
# upstream recommends. Entries match the whole `uses` value and apply in order.
|
||||
"action_replacements" => [
|
||||
{ "regex" => "builtin:checkout", "replacement" => "actions/checkout@v6" }
|
||||
]
|
||||
},
|
||||
"container" => {
|
||||
"network" => "gitea-actions" # User-defined bridge network: provides DNS for service containers
|
||||
# Empty: the runner auto-creates an isolated user-defined network per job, so
|
||||
# each job gets its own embedded DNS. Concurrent jobs can no longer collide on
|
||||
# service container names (e.g. two jobs both exposing a host named `redis`).
|
||||
"network" => ""
|
||||
},
|
||||
"cache" => {
|
||||
"enabled" => true,
|
||||
"host" => "172.20.0.1" # Gateway of the gitea-actions network, reachable from job containers
|
||||
# Empty: auto-detect the host address reachable from job containers. The runner
|
||||
# is a host binary (not containerized), so a per-job network resolves this to a
|
||||
# reachable gateway. Set explicitly only if detection picks a wrong interface.
|
||||
"host" => ""
|
||||
# Port is set per-runner (cache_base_port + index) in the runner recipe
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
# Increase if you have very long User-Agent strings
|
||||
map_hash_bucket_size 256;
|
||||
|
||||
# Bot user agents
|
||||
map $http_user_agent $bot_name {
|
||||
default "";
|
||||
~*ClaudeBot "claude";
|
||||
~*Sogou "sogou";
|
||||
~*meta-externalagent "meta-externalagent";
|
||||
# add more as needed
|
||||
}
|
||||
|
||||
# Decide the rate-limit key (per-IP for each bot in this example)
|
||||
map $bot_name $bot_limit_key {
|
||||
default "";
|
||||
"claude" $binary_remote_addr;
|
||||
"sogou" $binary_remote_addr;
|
||||
"meta-externalagent" $binary_remote_addr;
|
||||
}
|
||||
|
||||
# Shared memory zone – only non-empty keys are counted
|
||||
limit_req_zone $bot_limit_key zone=bots:20m rate=240r/m; # 4r/s per IP+bot
|
||||
|
||||
# Status code returned when the limit is exceeded
|
||||
limit_req_status 429;
|
||||
@@ -4,7 +4,7 @@ maintainer_email 'ops@kosmos.org'
|
||||
license 'MIT'
|
||||
description 'Installs/configures Gitea'
|
||||
long_description 'Installs/configures Gitea'
|
||||
version '0.3.4'
|
||||
version '0.3.10'
|
||||
chef_version '>= 14.0'
|
||||
|
||||
depends "firewall"
|
||||
|
||||
@@ -50,7 +50,7 @@ directory working_directory do
|
||||
mode "0750"
|
||||
end
|
||||
|
||||
%w(custom custom/options custom/options/label custom/templates custom/templates/custom).each do |path|
|
||||
%w(custom custom/options custom/options/label custom/public custom/templates custom/templates/custom).each do |path|
|
||||
directory "#{working_directory}/#{path}" do
|
||||
owner "git"
|
||||
group "git"
|
||||
@@ -76,6 +76,19 @@ cookbook_file "#{working_directory}/custom/templates/custom/header.tmpl" do
|
||||
notifies :restart, "service[gitea]", :delayed
|
||||
end
|
||||
|
||||
# robots.txt: hard-ban the crawlers listed in the data bag, and disallow
|
||||
# crawler-unfriendly filter permutations, expensive render routes and
|
||||
# combinatorial commit-browsing routes.
|
||||
bot_deny_user_agents = (gitea_data_bag_item["bot_filter"] || {})["deny_user_agents"] || []
|
||||
|
||||
template "#{working_directory}/custom/public/robots.txt" do
|
||||
source "robots.txt.erb"
|
||||
owner "git"
|
||||
group "git"
|
||||
mode "0644"
|
||||
variables deny_user_agents: bot_deny_user_agents
|
||||
end
|
||||
|
||||
directory config_directory do
|
||||
owner "git"
|
||||
group "git"
|
||||
|
||||
@@ -17,12 +17,23 @@ tls_cert_for domain do
|
||||
action :create
|
||||
end
|
||||
|
||||
# Slow down requests from bots
|
||||
cookbook_file "#{node["openresty"]["dir"]}/conf.d/rate_limits.conf" do
|
||||
source "rate_limits.conf"
|
||||
# Slow down / block unwanted bot traffic and hard-limit expensive routes.
|
||||
# The bot list and denied networks live in the `credentials/gitea` data bag so
|
||||
# they are not published in this repository.
|
||||
bot_filter = data_bag_item("credentials", "gitea")["bot_filter"] || {}
|
||||
limit_bots = bot_filter["limit"] || []
|
||||
deny_user_agents = bot_filter["deny_user_agents"] || []
|
||||
deny_networks = bot_filter["deny_networks"] || []
|
||||
|
||||
template "#{node["openresty"]["dir"]}/conf.d/rate_limits.conf" do
|
||||
source "rate_limits.conf.erb"
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0644"
|
||||
variables limit_bots: limit_bots,
|
||||
deny_user_agents: deny_user_agents,
|
||||
deny_networks: deny_networks
|
||||
notifies :reload, "service[openresty]", :delayed
|
||||
end
|
||||
|
||||
openresty_site domain do
|
||||
|
||||
@@ -38,9 +38,12 @@ directory "#{working_directory}/runners" do
|
||||
mode "0700"
|
||||
end
|
||||
|
||||
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"
|
||||
# One-time cleanup of the previously shared bridge network. Skipped while jobs are
|
||||
# still attached; the next converge removes it once the runner is idle.
|
||||
execute "remove_gitea_actions_network" do
|
||||
command "docker network rm gitea-actions"
|
||||
only_if "docker network inspect gitea-actions"
|
||||
not_if "docker network inspect -f '{{len .Containers}}' gitea-actions | grep -qv '^0$'"
|
||||
end
|
||||
|
||||
runners.each_with_index do |runner, index|
|
||||
@@ -59,7 +62,9 @@ runners.each_with_index do |runner, index|
|
||||
command :allow
|
||||
port cache_port
|
||||
protocol :tcp
|
||||
source "172.20.0.0/16"
|
||||
# Job containers now run on auto-created per-job networks, which Docker
|
||||
# allocates from its default address pool (172.16.0.0/12).
|
||||
source "172.16.0.0/12"
|
||||
end
|
||||
|
||||
template "#{runner_dir}/config.yaml" do
|
||||
|
||||
@@ -5,8 +5,8 @@ upstream _gitea_web {
|
||||
|
||||
server {
|
||||
server_name <%= @server_name %>;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
|
||||
ssl_certificate <%= @ssl_cert %>;
|
||||
ssl_certificate_key <%= @ssl_key %>;
|
||||
@@ -20,9 +20,20 @@ server {
|
||||
|
||||
proxy_intercept_errors on;
|
||||
|
||||
# Hard ban for user agents listed in the data bag. Defined in
|
||||
# /etc/openresty/conf.d/rate_limits.conf
|
||||
if ($deny_bot) { return 403; }
|
||||
|
||||
# Hard ban for networks listed in the data bag. Same file.
|
||||
if ($deny_ip) { return 403; }
|
||||
|
||||
# Rate limit for bots. Defined in /etc/openresty/conf.d/rate_limits.conf
|
||||
limit_req zone=bots burst=10; # allow a larger spike for asset bursts
|
||||
|
||||
# Hard limit for expensive render routes and filter-permutation list pages.
|
||||
# Only non-empty keys are counted, so normal requests are unaffected.
|
||||
limit_req zone=expensive burst=5 nodelay;
|
||||
|
||||
location ~ ^/(avatars|repo-avatars)/.*$ {
|
||||
proxy_buffers 1024 8k;
|
||||
proxy_pass http://_gitea_web;
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
# Managed by Chef. The rate-limited bot list, the hard-banned user agents and
|
||||
# the denied networks come from the `credentials/gitea` data bag (`bot_filter`),
|
||||
# so they are not published in this repository. Edit them there.
|
||||
map_hash_bucket_size 256;
|
||||
|
||||
# Rate-limited bots: user-agent pattern -> label. First match wins.
|
||||
map $http_user_agent $bot_name {
|
||||
default "";
|
||||
<% @limit_bots.each do |bot| -%>
|
||||
~*<%= bot["match"] %> "<%= bot["key"] %>";
|
||||
<% end -%>
|
||||
}
|
||||
|
||||
# Decide the rate-limit key (per-IP for each listed bot).
|
||||
map $bot_name $bot_limit_key {
|
||||
default "";
|
||||
<% @limit_bots.each do |bot| -%>
|
||||
"<%= bot["key"] %>" $binary_remote_addr;
|
||||
<% end -%>
|
||||
}
|
||||
|
||||
# Shared memory zone – only non-empty keys are counted.
|
||||
limit_req_zone $bot_limit_key zone=bots:20m rate=60r/m; # 1r/s per IP
|
||||
|
||||
# Status code returned when the limit is exceeded.
|
||||
limit_req_status 429;
|
||||
|
||||
# Hard-banned user agents, denied at the edge.
|
||||
map $http_user_agent $deny_bot {
|
||||
default 0;
|
||||
<% @deny_user_agents.each do |ua| -%>
|
||||
~*<%= ua %> 1;
|
||||
<% end -%>
|
||||
}
|
||||
|
||||
# Hard-banned networks: datacenter scrapers that spoof browser UAs, so they
|
||||
# cannot be caught by User-Agent.
|
||||
geo $deny_ip {
|
||||
default 0;
|
||||
<% @deny_networks.each do |cidr| -%>
|
||||
<%= cidr %> 1;
|
||||
<% end -%>
|
||||
}
|
||||
|
||||
# Expensive routes and filter-permutation list pages get a hard per-IP limit.
|
||||
# These are the pages crawlers enumerate combinatorially and that are CPU-heavy
|
||||
# to render (blame/compare/diff/syntax-highlight/signature verification).
|
||||
map $request_uri $expensive_request {
|
||||
default 0;
|
||||
~*^/[^/]+/[^/]+/blame/ 1;
|
||||
~*^/[^/]+/[^/]+/compare/ 1;
|
||||
~*^/[^/]+/[^/]+/raw/ 1;
|
||||
~*^/[^/]+/[^/]+/archive/ 1;
|
||||
~*\.(patch|diff)(\?|$) 1;
|
||||
~*^/[^/]+/[^/]+/(pulls|issues|milestones)\? 1;
|
||||
}
|
||||
|
||||
# Only non-empty keys are counted, so normal requests are never throttled here.
|
||||
map $expensive_request $expensive_key {
|
||||
default "";
|
||||
"1" $binary_remote_addr;
|
||||
}
|
||||
|
||||
limit_req_zone $expensive_key zone=expensive:20m rate=10r/m; # ~1 per 6s per IP
|
||||
@@ -0,0 +1,20 @@
|
||||
# Managed by Chef. The hard-banned crawlers come from the `credentials/gitea`
|
||||
# data bag (`bot_filter`), so their names are not published in this repository.
|
||||
<% @deny_user_agents.each do |ua| -%>
|
||||
User-agent: <%= ua %>
|
||||
Disallow: /
|
||||
<% end -%>
|
||||
|
||||
# Everyone else: keep normal pages crawlable, but never crawl filter
|
||||
# permutations on list pages, the expensive render routes or commit browsing.
|
||||
User-agent: *
|
||||
Disallow: /*?*
|
||||
Disallow: /*/blame/
|
||||
Disallow: /*/compare/
|
||||
Disallow: /*/raw/
|
||||
Disallow: /*/archive/
|
||||
Disallow: /*/src/commit/
|
||||
Disallow: /*/commits/commit/
|
||||
Disallow: /*.patch$
|
||||
Disallow: /*.diff$
|
||||
Allow: /
|
||||
@@ -5,6 +5,7 @@ driver:
|
||||
|
||||
provisioner:
|
||||
name: dokken
|
||||
product_name: cinc
|
||||
|
||||
transport:
|
||||
name: dokken
|
||||
|
||||
@@ -11,8 +11,8 @@ upstream _<%= @app_name %> {
|
||||
# variables_hash_max_size 2048;
|
||||
|
||||
server {
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
server_name <%= @server_name %>;
|
||||
|
||||
access_log <%= node[:nginx][:log_dir] %>/<%= @app_name %>.access.log; # TODO json_liquor_cabinet;
|
||||
|
||||
@@ -59,6 +59,10 @@ systemd_unit "node_exporter.service" do
|
||||
User: "node_exporter",
|
||||
Group: "node_exporter",
|
||||
ExecStart: "/usr/local/bin/node_exporter --web.listen-address=:#{node_exporter_port} --collector.textfile.directory=/var/lib/node_exporter/textfile",
|
||||
# node_exporter 1.11.1 is built with Go >= 1.24, which opens MPTCP
|
||||
# listeners by default on Linux since 5.6. That is the precondition of
|
||||
# the CVE-2026-98432 exploit, and we do not need MPTCP, so opt out.
|
||||
Environment: "GODEBUG=multipathtcp=0",
|
||||
Restart: "on-failure",
|
||||
RestartSec: "5",
|
||||
NoNewPrivileges: "yes",
|
||||
@@ -70,6 +74,7 @@ systemd_unit "node_exporter.service" do
|
||||
},
|
||||
})
|
||||
triggers_reload true
|
||||
notifies :restart, "service[node_exporter]", :delayed
|
||||
action :create
|
||||
end
|
||||
|
||||
|
||||
@@ -2,6 +2,19 @@
|
||||
|
||||
This file is used to list changes made in each version of the kosmos_rsk cookbook.
|
||||
|
||||
## 0.6.1
|
||||
|
||||
* Manage `/etc/rsk/node.conf` and the RPC/node config from Chef. The rskj
|
||||
package owns `node.conf` and rewrites it on every configure based on the
|
||||
`shared/config` debconf answer, which is not reliably preserved across
|
||||
upgrades; after a plain package upgrade the question fell back to the default
|
||||
(`mainnet`), so upgraded testnet nodes started syncing the wrong chain.
|
||||
|
||||
## 0.6.0
|
||||
|
||||
* Bump rskj to 9.0.5 (mitigates CVE-2026-114938)
|
||||
* Restart rsk after the package upgrade (the package itself does not)
|
||||
|
||||
## 0.3.0
|
||||
|
||||
* Bump rskj version
|
||||
|
||||
@@ -1,4 +1,22 @@
|
||||
node.default['rskj']['version'] = "9.0.1~#{node['lsb']['codename']}"
|
||||
node.default['rskj']['version'] = "9.0.5~#{node['lsb']['codename']}"
|
||||
node.default['rskj']['network'] = 'testnet'
|
||||
|
||||
node.default['rskj']['nginx']['domain'] = nil
|
||||
|
||||
# RPC settings for the managed node config (templates/kosmos-node.conf.erb).
|
||||
# The node sits behind the openresty RSK proxies, so it listens on all
|
||||
# interfaces and the proxies add the CORS headers the public API needs.
|
||||
node.default['rskj']['rpc']['bind_address'] = '0.0.0.0'
|
||||
node.default['rskj']['rpc']['cors'] = '*'
|
||||
node.default['rskj']['rpc']['port'] = 4444
|
||||
node.default['rskj']['rpc']['modules'] = {
|
||||
'eth' => 'true',
|
||||
'net' => 'true',
|
||||
'rpc' => 'true',
|
||||
'web3' => 'true',
|
||||
'evm' => 'false',
|
||||
'sco' => 'false',
|
||||
'txpool' => 'true',
|
||||
'debug' => 'false',
|
||||
'personal' => 'true'
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
---
|
||||
driver:
|
||||
name: dokken
|
||||
chef_version: 18.2.7
|
||||
pull_platform_image: false
|
||||
pull_chef_image: false
|
||||
memory_limit: 2147483648 # 2GB
|
||||
@@ -25,10 +24,8 @@ provisioner:
|
||||
# always_update_cookbooks: <%= !ENV['CI'] %>
|
||||
# always_update_cookbooks: false
|
||||
|
||||
## product_name and product_version specifies a specific Chef product and version to install.
|
||||
## see the Chef documentation for more details: https://docs.chef.io/workstation/config_yml_kitchen/
|
||||
# product_name: chef
|
||||
# product_version: 16
|
||||
# install Cinc Client instead of the license-gated Chef Infra Client
|
||||
product_name: cinc
|
||||
|
||||
verifier:
|
||||
name: inspec
|
||||
|
||||
@@ -3,7 +3,7 @@ maintainer 'Kosmos Developers'
|
||||
maintainer_email 'ops@kosmos.org'
|
||||
license 'MIT'
|
||||
description 'Installs/configures RSKj and related software'
|
||||
version '0.5.0'
|
||||
version '0.6.1'
|
||||
chef_version '>= 18.2'
|
||||
issues_url 'https://gitea.kosmos.org/kosmos/chef/issues'
|
||||
source_url 'https://gitea.kosmos.org/kosmos/chef'
|
||||
|
||||
@@ -27,14 +27,42 @@ execute 'preseed-rskj-license' do
|
||||
not_if 'debconf-get-selections | grep -q "shared/accepted-rsk-license-v1-1.*true"'
|
||||
end
|
||||
|
||||
execute 'preseed-rskj-config' do
|
||||
command "echo \"rskj shared/config select #{node['rskj']['network']}\" | debconf-set-selections"
|
||||
not_if "debconf-get-selections | grep -q \"shared/config.*#{node['rskj']['network']}\""
|
||||
end
|
||||
|
||||
apt_package 'rskj' do
|
||||
options '--assume-yes'
|
||||
version node['rskj']['version']
|
||||
# The package upgrade does not restart the node itself, so do it for it.
|
||||
notifies :restart, 'service[rsk]', :delayed
|
||||
end
|
||||
|
||||
# The rskj package owns /etc/rsk/node.conf: its postinst re-asks the
|
||||
# `shared/config` debconf question on every configure and re-points node.conf at
|
||||
# the selected network's shipped config. That debconf state is not reliably
|
||||
# preserved across upgrades -- after a plain package upgrade the question fell
|
||||
# back to the template default ("mainnet") and the node began syncing the wrong
|
||||
# chain from scratch. The shipped configs also bind RPC to 127.0.0.1, which the
|
||||
# openresty proxies cannot reach. So manage our own config and the node.conf
|
||||
# symlink from Chef, after the package has been configured, so a package upgrade
|
||||
# can no longer mis-network the node.
|
||||
rskj_network = node['rskj']['network']
|
||||
rskj_rpc_hosts = ['localhost']
|
||||
rskj_rpc_hosts << node['rskj']['nginx']['domain'] if node['rskj']['nginx']['domain']
|
||||
|
||||
template "/etc/rsk/kosmos-#{rskj_network}.conf" do
|
||||
source 'kosmos-node.conf.erb'
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0644'
|
||||
variables(
|
||||
network: rskj_network,
|
||||
rpc: node['rskj']['rpc'],
|
||||
hosts: rskj_rpc_hosts
|
||||
)
|
||||
notifies :restart, 'service[rsk]', :delayed
|
||||
end
|
||||
|
||||
link '/etc/rsk/node.conf' do
|
||||
to "/etc/rsk/kosmos-#{rskj_network}.conf"
|
||||
notifies :restart, 'service[rsk]', :delayed
|
||||
end
|
||||
|
||||
service "rsk" do
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
blockchain.config.name = "<%= @network %>"
|
||||
|
||||
database.dir = /var/lib/rsk/database/<%= @network %>
|
||||
|
||||
rpc {
|
||||
providers : {
|
||||
web: {
|
||||
cors: "<%= @rpc['cors'] %>",
|
||||
http: {
|
||||
enabled: true,
|
||||
bind_address = "<%= @rpc['bind_address'] %>",
|
||||
hosts = [<%= @hosts.map { |host| "\"#{host}\"" }.join(',') %>]
|
||||
port: <%= @rpc['port'] %>,
|
||||
}
|
||||
ws: {
|
||||
enabled: false,
|
||||
bind_address: "<%= @rpc['bind_address'] %>",
|
||||
port: 4445,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
modules = [
|
||||
<% @rpc['modules'].each do |name, enabled| -%>
|
||||
{
|
||||
name: "<%= name %>",
|
||||
version: "1.0",
|
||||
enabled: "<%= enabled %>"
|
||||
},
|
||||
<% end -%>
|
||||
]
|
||||
}
|
||||
@@ -5,8 +5,8 @@ upstream _<%= @upstream_name %> {
|
||||
}
|
||||
|
||||
server {
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
|
||||
server_name <%= @domain %>;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ end
|
||||
|
||||
describe package('rskj') do
|
||||
it { should be_installed }
|
||||
its('version') { should eq '9.0.1~noble' }
|
||||
its('version') { should eq '9.0.5~noble' }
|
||||
end
|
||||
|
||||
describe service('rsk') do
|
||||
@@ -18,6 +18,11 @@ describe service('rsk') do
|
||||
it { should be_running }
|
||||
end
|
||||
|
||||
# 9.0.5 disables the vulnerable JDK Base64 intrinsic (CVE-2026-114938)
|
||||
describe file('/lib/systemd/system/rsk.service') do
|
||||
its('content') { should match(/-XX:-UseBASE64Intrinsics/) }
|
||||
end
|
||||
|
||||
describe port(4444) do
|
||||
it { should be_listening }
|
||||
end
|
||||
@@ -28,3 +33,18 @@ describe parse_config_file('/etc/rsk/node.conf', {
|
||||
its(['blockchain.config.name']) { should eq '"testnet"' }
|
||||
its(['database.dir']) { should eq '/var/lib/rsk/database/testnet' }
|
||||
end
|
||||
|
||||
# The node config and the node.conf symlink are managed by Chef, so a package
|
||||
# upgrade can no longer reset them to the default (mainnet) network.
|
||||
describe file('/etc/rsk/kosmos-testnet.conf') do
|
||||
it { should exist }
|
||||
its('content') { should match(/^blockchain\.config\.name = "testnet"$/) }
|
||||
its('content') { should match(%r{^database\.dir = /var/lib/rsk/database/testnet$}) }
|
||||
its('content') { should match(/bind_address = "0\.0\.0\.0"/) }
|
||||
its('content') { should match(/cors: "\*"/) }
|
||||
end
|
||||
|
||||
describe file('/etc/rsk/node.conf') do
|
||||
it { should be_symlink }
|
||||
its('link_path') { should eq '/etc/rsk/kosmos-testnet.conf' }
|
||||
end
|
||||
@@ -2,3 +2,25 @@ kosmos_strfry
|
||||
=============
|
||||
|
||||
Installs/configures a strfry relay and its reverse proxy config
|
||||
|
||||
## Tests
|
||||
|
||||
`test/strfry_sync_conf_test.rb` is a standalone regression check for
|
||||
`templates/strfry_sync.conf.erb` (the `kosmos_strfry::approved_sync` sync
|
||||
config). It asserts that the sync's `rejectEventsOlderThanSeconds` age floor is
|
||||
present and positive, because `0` does *not* disable the check in strfry — it
|
||||
rejects every synced event. No Chef server or converge is required:
|
||||
|
||||
```
|
||||
ruby site-cookbooks/kosmos_strfry/test/strfry_sync_conf_test.rb
|
||||
```
|
||||
|
||||
`test/member_bridge_conf_test.rb` is a standalone regression check for
|
||||
`templates/member_bridge.conf.erb` (the `kosmos_strfry::member_bridge` router
|
||||
config). It asserts that the stream group is one-way (`dir = "down"`) and gated
|
||||
by the LDAP-only policy (`pluginDown`), with a space-free plugin path so strfry
|
||||
hot-reloads it. No Chef server or converge is required:
|
||||
|
||||
```
|
||||
ruby site-cookbooks/kosmos_strfry/test/member_bridge_conf_test.rb
|
||||
```
|
||||
@@ -1,6 +1,27 @@
|
||||
node.default["strfry"]["ldap_search_dn"] = "ou=kosmos.org,cn=users,dc=kosmos,dc=org"
|
||||
node.default["strfry"]["extras_dir"] = "/opt/strfry"
|
||||
|
||||
#
|
||||
# approved sync (WS3): pull worker-approved events from the staging relay into
|
||||
# the production database. See kosmos_strfry/recipes/approved_sync.rb.
|
||||
#
|
||||
node.default["strfry"]["staging_relay_url"] = "ws://10.1.1.183:7779"
|
||||
node.default["strfry"]["approved_sync"]["enabled"] = false
|
||||
node.default["strfry"]["approved_sync"]["config_file"] = "/etc/strfry-sync.conf"
|
||||
node.default["strfry"]["approved_sync"]["policy_url"] = "https://gitea.kosmos.org/kosmos/akkounts/raw/branch/live/extras/strfry/sync-policy.mjs"
|
||||
|
||||
#
|
||||
# member bridge (WS3): live one-way promotion of member-authored events from the
|
||||
# local submission relay into the production database, gated by the LDAP-only
|
||||
# write policy. See kosmos_strfry/recipes/member_bridge.rb.
|
||||
#
|
||||
node.default["strfry"]["member_bridge"]["enabled"] = false
|
||||
node.default["strfry"]["member_bridge"]["config_file"] = "/etc/strfry-member-bridge.conf"
|
||||
node.default["strfry"]["member_bridge"]["subscribe_relay"] = "ws://localhost:7778"
|
||||
node.default["strfry"]["member_bridge"]["plugin_cmd"] = "#{node["strfry"]["extras_dir"]}/ldap-only-policy.ts"
|
||||
node.default["strfry"]["member_bridge"]["kinds"] = [0, 3, 5, 360, 30360]
|
||||
node.default["strfry"]["member_bridge"]["connection_timeout"] = 20
|
||||
|
||||
# node.default["substr"]["repo"] = "https://gitea.kosmos.org/kosmos/substr.git"
|
||||
# node.default["substr"]["revision"] = "master"
|
||||
node.default["substr"]["version"] = "nightly"
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
#
|
||||
# Cookbook Name:: kosmos_strfry
|
||||
# Recipe:: approved_sync
|
||||
#
|
||||
# Pull moderator-approved events from the nuc staging relay (ws://<nuc>:7779)
|
||||
# into the production LMDB database used by nostr.kosmos.org, without exposing
|
||||
# a public write path into it. This is the only way non-member, VLM-approved
|
||||
# content reaches the production relay.
|
||||
#
|
||||
# The sync runs against a DEDICATED config (/etc/strfry-sync.conf) that points
|
||||
# at the SAME database as the production relay but installs a fail-closed write
|
||||
# policy (sync-policy.mjs): only events with sourceType="Sync" and a byte-exact
|
||||
# sourceInfo match for STAGING_RELAY_URL are accepted.
|
||||
#
|
||||
# This recipe is a no-op until node["strfry"]["approved_sync"]["enabled"] is
|
||||
# set to true (e.g. in an environment or a node's role overrides).
|
||||
#
|
||||
|
||||
unless node["strfry"]["approved_sync"]["enabled"]
|
||||
Chef::Log.info("kosmos_strfry::approved_sync is disabled; skipping staged-event sync.")
|
||||
return
|
||||
end
|
||||
|
||||
config_file = node["strfry"]["approved_sync"]["config_file"]
|
||||
staging_url = node["strfry"]["staging_relay_url"]
|
||||
extras_dir = node["strfry"]["extras_dir"]
|
||||
|
||||
if staging_url.to_s.empty?
|
||||
raise "node['strfry']['staging_relay_url'] must be set when approved_sync is enabled"
|
||||
end
|
||||
|
||||
directory extras_dir do
|
||||
owner node["strfry"]["user"]
|
||||
group node["strfry"]["group"]
|
||||
mode "0755"
|
||||
end
|
||||
|
||||
#
|
||||
# Fail-closed write policy. Deployed here (and not in ::policies) because it is
|
||||
# only meaningful together with the sync config.
|
||||
#
|
||||
remote_file "#{extras_dir}/sync-policy.mjs" do
|
||||
source node["strfry"]["approved_sync"]["policy_url"]
|
||||
owner node["strfry"]["user"]
|
||||
group node["strfry"]["group"]
|
||||
mode "0755"
|
||||
end
|
||||
|
||||
#
|
||||
# Config: identical db + settings as the production relay, except that we keep
|
||||
# arbitrarily old events (approved long after submission) and swap in the
|
||||
# sync-only write policy.
|
||||
#
|
||||
prod_config = node["strfry"]["config"]
|
||||
prod_db_params = prod_config["db_params"] || {}
|
||||
prod_relay = prod_config["relay"] || {}
|
||||
|
||||
template config_file do
|
||||
source "strfry_sync.conf.erb"
|
||||
owner node["strfry"]["user"]
|
||||
group node["strfry"]["group"]
|
||||
mode "0644"
|
||||
variables db: prod_config["db"],
|
||||
maxreaders: prod_db_params["maxreaders"] || "256",
|
||||
mapsize: prod_db_params["mapsize"] || "10995116277760",
|
||||
no_read_ahead: prod_db_params["no_read_ahead"] || "false",
|
||||
nofiles: prod_relay["nofiles"] || "524288",
|
||||
plugin: "node #{extras_dir}/sync-policy.mjs",
|
||||
timeout_seconds: 10
|
||||
end
|
||||
|
||||
#
|
||||
# Oneshot sync, driven by a timer. `sync --dir down` is one-way (staging ->
|
||||
# production) and DOES run the local write policy with sourceType="Sync" and
|
||||
# sourceInfo=<staging URL> (see strfry src/apps/mesh/cmd_sync.cpp). No --filter:
|
||||
# the worker only ever publishes approved events to the staging relay, and the
|
||||
# policy rejects everything else.
|
||||
#
|
||||
systemd_unit "strfry-sync.service" do
|
||||
content({
|
||||
Unit: {
|
||||
Description: "strfry approved-event sync (staging -> production)",
|
||||
Documentation: ["https://github.com/hoytech/strfry"],
|
||||
After: "strfry.service",
|
||||
Wants: "network-online.target"
|
||||
},
|
||||
Service: {
|
||||
Type: "oneshot",
|
||||
User: node["strfry"]["user"],
|
||||
Group: node["strfry"]["group"],
|
||||
ExecStart: "/usr/local/bin/strfry --config #{config_file} sync #{staging_url} --dir down",
|
||||
# sync-policy.mjs compares sourceInfo byte-for-byte against this value.
|
||||
Environment: ["STAGING_RELAY_URL=#{staging_url}"],
|
||||
Nice: 10,
|
||||
ProtectHome: "no",
|
||||
NoNewPrivileges: "yes",
|
||||
ProtectSystem: "full",
|
||||
LimitCORE: "0",
|
||||
TimeoutStartSec: "600"
|
||||
},
|
||||
Install: {
|
||||
WantedBy: "multi-user.target"
|
||||
}
|
||||
})
|
||||
triggers_reload true
|
||||
action :create
|
||||
end
|
||||
|
||||
systemd_unit "strfry-sync.timer" do
|
||||
content({
|
||||
Unit: {
|
||||
Description: "Run the approved-event sync every 5 minutes"
|
||||
},
|
||||
Timer: {
|
||||
OnCalendar: "*-*-* *:0/5:00",
|
||||
Persistent: "true"
|
||||
},
|
||||
Install: {
|
||||
WantedBy: "timers.target"
|
||||
}
|
||||
})
|
||||
triggers_reload true
|
||||
action [:create, :enable, :start]
|
||||
end
|
||||
@@ -0,0 +1,70 @@
|
||||
#
|
||||
# Cookbook Name:: kosmos_strfry
|
||||
# Recipe:: member_bridge
|
||||
#
|
||||
# Live, one-way promotion of member-authored events from the local submission
|
||||
# relay (ws://localhost:7778) into the production database used by
|
||||
# nostr.kosmos.org.
|
||||
#
|
||||
# It runs `strfry router` with a stream group whose `dir` is "down" (so the
|
||||
# router never watches or forwards the local database) and whose `pluginDown` is
|
||||
# the LDAP-only write policy (/opt/strfry/ldap-only-policy.ts). Membership is
|
||||
# therefore decided per event by LDAP; no member list is maintained, and
|
||||
# non-member events are rejected before they reach the database.
|
||||
#
|
||||
# This recipe is a no-op until node["strfry"]["member_bridge"]["enabled"] is set
|
||||
# to true (in an environment or a node's role overrides).
|
||||
#
|
||||
|
||||
unless node["strfry"]["member_bridge"]["enabled"]
|
||||
Chef::Log.info("kosmos_strfry::member_bridge is disabled; skipping member bridge.")
|
||||
return
|
||||
end
|
||||
|
||||
config_file = node["strfry"]["member_bridge"]["config_file"]
|
||||
|
||||
template config_file do
|
||||
source "member_bridge.conf.erb"
|
||||
owner node["strfry"]["user"]
|
||||
group node["strfry"]["group"]
|
||||
mode "0644"
|
||||
variables subscribe_relay: node["strfry"]["member_bridge"]["subscribe_relay"],
|
||||
plugin_cmd: node["strfry"]["member_bridge"]["plugin_cmd"],
|
||||
kinds: node["strfry"]["member_bridge"]["kinds"],
|
||||
connection_timeout: node["strfry"]["member_bridge"]["connection_timeout"]
|
||||
end
|
||||
|
||||
#
|
||||
# `strfry router` reads /etc/strfry.conf for the database and the router config
|
||||
# for the stream groups. It writes accepted events straight into the production
|
||||
# LMDB (the same multi-process access pattern already used by the approved sync).
|
||||
#
|
||||
systemd_unit "strfry-member-bridge.service" do
|
||||
content({
|
||||
Unit: {
|
||||
Description: "strfry member bridge (submission relay -> production, LDAP-only)",
|
||||
Documentation: ["https://github.com/hoytech/strfry"],
|
||||
After: "strfry.service",
|
||||
Wants: "network-online.target"
|
||||
},
|
||||
Service: {
|
||||
Type: "simple",
|
||||
User: node["strfry"]["user"],
|
||||
Group: node["strfry"]["group"],
|
||||
ExecStart: "/usr/local/bin/strfry router #{config_file}",
|
||||
Restart: "on-failure",
|
||||
RestartSec: "5",
|
||||
Nice: 10,
|
||||
# The LDAP-only policy is a Deno script; Deno caches its modules under the
|
||||
# strfry user's home, so ProtectHome must stay off (as for strfry.service).
|
||||
ProtectHome: "no",
|
||||
NoNewPrivileges: "yes",
|
||||
ProtectSystem: "full"
|
||||
},
|
||||
Install: {
|
||||
WantedBy: "multi-user.target"
|
||||
}
|
||||
})
|
||||
triggers_reload true
|
||||
action [:create, :enable, :start]
|
||||
end
|
||||
@@ -81,3 +81,14 @@ remote_file "#{extras_dir}/strfry-sync.ts" do
|
||||
group node["strfry"]["group"]
|
||||
mode "0644"
|
||||
end
|
||||
|
||||
# LDAP-only policy for the member bridge (kosmos_strfry::member_bridge). It
|
||||
# reuses ldap-policy.ts above. No `notifies` is needed: strfry watches the
|
||||
# plugin file's mtime (the pluginDown path contains no spaces) and restarts it
|
||||
# on change.
|
||||
remote_file "#{extras_dir}/ldap-only-policy.ts" do
|
||||
source "#{base_url}/ldap-only-policy.ts"
|
||||
owner node["strfry"]["user"]
|
||||
group node["strfry"]["group"]
|
||||
mode "0755"
|
||||
end
|
||||
@@ -0,0 +1,20 @@
|
||||
# Managed by Chef (kosmos_strfry::member_bridge). Do not edit by hand.
|
||||
#
|
||||
# Live member bridge: a `strfry router` stream group subscribes to the local
|
||||
# submission relay and writes member-authored events into the production relay's
|
||||
# database. Membership is decided per event by the LDAP-only write policy
|
||||
# (pluginDown); no member list is maintained here.
|
||||
#
|
||||
# `dir = "down"` keeps this strictly one-way: the router never watches or
|
||||
# forwards the local database.
|
||||
|
||||
connectionTimeout = <%= @connection_timeout %>
|
||||
|
||||
streams {
|
||||
members {
|
||||
dir = "down"
|
||||
filter = { "kinds": [<%= @kinds.join(', ') %>] }
|
||||
urls = [ "<%= @subscribe_relay %>" ]
|
||||
pluginDown = "<%= @plugin_cmd %>"
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,8 @@ upstream _substr {
|
||||
|
||||
server {
|
||||
server_name <%= @domain %>;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
|
||||
access_log "/var/log/nginx/<%= @domain %>.access.log";
|
||||
error_log "/var/log/nginx/<%= @domain %>.error.log";
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
# Managed by Chef (kosmos_strfry::approved_sync). Do not edit by hand.
|
||||
#
|
||||
# Dedicated config for `strfry sync` (staging -> production ingestion). It uses
|
||||
# the SAME LMDB database as the production relay (<%= @db %>), but installs a
|
||||
# fail-closed write policy that only accepts events synced from the staging
|
||||
# relay.
|
||||
#
|
||||
# Only the settings that matter for a sync-only process are set here; everything
|
||||
# else falls back to strfry's compiled-in defaults.
|
||||
|
||||
db = "<%= @db %>/"
|
||||
|
||||
dbParams {
|
||||
# This opens the production relay's existing LMDB map file; it is NOT a new
|
||||
# allocation. maxreaders/mapsize must therefore match (or exceed) what the
|
||||
# running production relay uses -- hence the fallbacks are the production
|
||||
# relay's values (strfry's 10 TB default mapsize).
|
||||
maxreaders = <%= @maxreaders %>
|
||||
mapsize = <%= @mapsize %>
|
||||
noReadAhead = <%= @no_read_ahead %>
|
||||
}
|
||||
|
||||
events {
|
||||
# Approved events reach the staging relay long after they were created, so
|
||||
# the age floor is effectively disabled here (100 years).
|
||||
#
|
||||
# NOTE: 0 does NOT disable this check in strfry. strfry computes
|
||||
# earliest = now - rejectEventsOlderThanSeconds
|
||||
# so 0 makes earliest == now and rejects EVERY event with
|
||||
# "created_at too early" -- before the write policy is even consulted.
|
||||
# Use a large bound instead.
|
||||
rejectEventsOlderThanSeconds = 3153600000
|
||||
}
|
||||
|
||||
relay {
|
||||
# strfry raises RLIMIT_NOFILE to this value at startup and exits if it
|
||||
# exceeds the process hard limit. The compiled-in default (1000000) is above
|
||||
# the systemd default here (524288), which made the sync fail to start with
|
||||
# "Unable to set NOFILES limit to 1000000". Set it explicitly, matching the
|
||||
# production relay config.
|
||||
nofiles = <%= @nofiles %>
|
||||
writePolicy {
|
||||
plugin = "<%= @plugin %>"
|
||||
timeoutSeconds = <%= @timeout_seconds %>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Regression check for kosmos_strfry/templates/member_bridge.conf.erb.
|
||||
#
|
||||
# The member bridge is a `strfry router` stream group. Two properties must hold,
|
||||
# or the bridge is either not one-way or not a member gate:
|
||||
# * `dir` must be "down" (the router must never watch/forward the local DB), and
|
||||
# * `pluginDown` must be the LDAP-only policy, with a path that contains no
|
||||
# spaces (strfry only hot-reloads space-free plugin paths).
|
||||
#
|
||||
# Renders the real template (no Chef server needed) with the attribute shapes
|
||||
# kosmos_strfry::member_bridge passes.
|
||||
#
|
||||
# Run standalone: ruby site-cookbooks/kosmos_strfry/test/member_bridge_conf_test.rb
|
||||
|
||||
require 'erb'
|
||||
|
||||
TEMPLATE = File.expand_path('../templates/member_bridge.conf.erb', __dir__)
|
||||
|
||||
DEFAULTS = {
|
||||
subscribe_relay: 'ws://localhost:7778',
|
||||
plugin_cmd: '/opt/strfry/ldap-only-policy.ts',
|
||||
kinds: [0, 3, 5, 360, 30360],
|
||||
connection_timeout: 20
|
||||
}.freeze
|
||||
|
||||
def render(vars)
|
||||
context = Object.new
|
||||
vars.each { |name, value| context.instance_variable_set("@#{name}", value) }
|
||||
|
||||
# Chef renders templates with the `variables` hash exposed as instance
|
||||
# variables (@subscribe_relay, ...); mirror that with a bare binding.
|
||||
ERB.new(File.read(TEMPLATE), trim_mode: '-').result(context.instance_eval { binding })
|
||||
end
|
||||
|
||||
def check(description, vars)
|
||||
rendered = render(vars)
|
||||
|
||||
unless rendered.match?(/^\s*dir\s*=\s*"down"\s*$/)
|
||||
raise "#{description}: dir must be \"down\""
|
||||
end
|
||||
if rendered.match?(/^\s*dir\s*=\s*"(up|both)"\s*$/)
|
||||
raise "#{description}: dir must not be up/both (the bridge must be one-way)"
|
||||
end
|
||||
|
||||
unless rendered.include?(%(urls = [ "#{vars[:subscribe_relay]}" ]))
|
||||
raise "#{description}: urls does not contain the subscribe relay"
|
||||
end
|
||||
|
||||
unless rendered.include?(%(pluginDown = "#{vars[:plugin_cmd]}"))
|
||||
raise "#{description}: pluginDown does not point at the LDAP-only policy"
|
||||
end
|
||||
|
||||
if vars[:plugin_cmd].include?(' ')
|
||||
raise "#{description}: plugin path must contain no spaces (strfry only hot-reloads space-free paths)"
|
||||
end
|
||||
|
||||
unless rendered.include?(%(filter = { "kinds": [#{vars[:kinds].join(', ')}] }))
|
||||
raise "#{description}: kinds filter missing or unexpected"
|
||||
end
|
||||
|
||||
unless rendered.include?("connectionTimeout = #{vars[:connection_timeout]}")
|
||||
raise "#{description}: connectionTimeout missing"
|
||||
end
|
||||
|
||||
puts "ok - #{description}"
|
||||
end
|
||||
|
||||
begin
|
||||
check('default attributes', DEFAULTS)
|
||||
puts "\nPASS: member_bridge.conf.erb is one-way and gated by the LDAP-only policy."
|
||||
rescue StandardError => e
|
||||
warn "FAIL: #{e.message}"
|
||||
exit 1
|
||||
end
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Regression check for kosmos_strfry/templates/strfry_sync.conf.erb.
|
||||
#
|
||||
# Background: `strfry sync` must accept events that were created long before
|
||||
# they were approved, so the sync config sets a 100-year age floor. The counter
|
||||
# intuitive part (see doc/nostr-submission-relay.md) is that 0 does NOT disable
|
||||
# the check in strfry -- it computes `earliest = now - rejectEventsOlderThanSeconds`,
|
||||
# so 0 rejects every event. This test renders the real template (no Chef server
|
||||
# needed) with the same attribute shapes that kosmos_strfry::approved_sync
|
||||
# passes, and fails if the age floor is missing or non-positive.
|
||||
#
|
||||
# Run standalone: ruby site-cookbooks/kosmos_strfry/test/strfry_sync_conf_test.rb
|
||||
#
|
||||
# No Chef server / converge required: this only needs the chef gem (for
|
||||
# ImmutableMash, to mirror the recipe's attribute lookups) and stdlib ERB.
|
||||
|
||||
require 'erb'
|
||||
require 'chef' # Chef::Node::ImmutableMash
|
||||
|
||||
TEMPLATE = File.expand_path('../templates/strfry_sync.conf.erb', __dir__)
|
||||
|
||||
# The comment in the template mentions "0" a few times; only real settings (a
|
||||
# `key = value` line with the key at the start of the line) must be validated.
|
||||
SETTING_RE = /^\s*rejectEventsOlderThanSeconds\s*=\s*(-?\d+)\s*$/.freeze
|
||||
NOFILES_RE = /^\s*nofiles\s*=\s*(\d+)\s*$/.freeze
|
||||
EXPECTED_AGE_FLOOR = 3_153_600_000 # 100 years
|
||||
|
||||
def render(node)
|
||||
prod_config = node['strfry']['config']
|
||||
prod_db_params = prod_config['db_params'] || {}
|
||||
prod_relay = prod_config['relay'] || {}
|
||||
|
||||
# Same variable shapes kosmos_strfry/recipes/approved_sync.rb passes to the
|
||||
# template resource (keep in sync if that recipe changes).
|
||||
vars = {
|
||||
db: prod_config['db'],
|
||||
maxreaders: prod_db_params['maxreaders'] || '256',
|
||||
mapsize: prod_db_params['mapsize'] || '10995116277760',
|
||||
no_read_ahead: prod_db_params['no_read_ahead'] || 'false',
|
||||
nofiles: prod_relay['nofiles'] || '524288',
|
||||
plugin: 'node /opt/strfry/sync-policy.mjs',
|
||||
timeout_seconds: 10
|
||||
}
|
||||
|
||||
# Chef renders templates with the `variables` hash exposed as instance
|
||||
# variables (@db, @maxreaders, ...); mirror that with a bare binding.
|
||||
context = Object.new
|
||||
vars.each { |name, value| context.instance_variable_set("@#{name}", value) }
|
||||
|
||||
ERB.new(File.read(TEMPLATE), trim_mode: '-').result(context.instance_eval { binding })
|
||||
end
|
||||
|
||||
def check_node(description, node)
|
||||
rendered = render(node)
|
||||
|
||||
match = rendered.match(SETTING_RE)
|
||||
raise "#{description}: render has no `rejectEventsOlderThanSeconds = <int>` setting" if match.nil?
|
||||
|
||||
value = match[1].to_i
|
||||
if value <= 0
|
||||
raise "#{description}: rejectEventsOlderThanSeconds = #{value} (must be > 0; 0 rejects every synced event)"
|
||||
end
|
||||
if value != EXPECTED_AGE_FLOOR
|
||||
raise "#{description}: rejectEventsOlderThanSeconds = #{value}, expected #{EXPECTED_AGE_FLOOR}"
|
||||
end
|
||||
unless rendered.include?('rejectEventsOlderThanSeconds = 3153600000')
|
||||
raise "#{description}: literal `rejectEventsOlderThanSeconds = 3153600000` not found in render"
|
||||
end
|
||||
|
||||
# Sanity-check the other settings the recipe derives, so a broken fallback
|
||||
# (e.g. an empty db) is caught too.
|
||||
unless rendered.include?("db = \"#{node['strfry']['config']['db']}/\"")
|
||||
raise "#{description}: db setting does not match node attribute"
|
||||
end
|
||||
raise "#{description}: writePolicy block missing" unless rendered.include?('writePolicy')
|
||||
|
||||
# strfry raises RLIMIT_NOFILE to `nofiles` at startup and exits if that
|
||||
# exceeds the process hard limit. The compiled-in default (1000000) is above
|
||||
# the systemd default (524288), so the template must set it explicitly.
|
||||
nofiles_match = rendered.match(NOFILES_RE)
|
||||
raise "#{description}: render has no `nofiles = <int>` setting" if nofiles_match.nil?
|
||||
|
||||
expected_nofiles = (node['strfry']['config']['relay'] || {})['nofiles'] || '524288'
|
||||
if nofiles_match[1] != expected_nofiles.to_s
|
||||
raise "#{description}: nofiles = #{nofiles_match[1]}, expected #{expected_nofiles}"
|
||||
end
|
||||
|
||||
puts "ok - #{description} (rejectEventsOlderThanSeconds = #{value}, nofiles = #{nofiles_match[1]})"
|
||||
end
|
||||
|
||||
# Representative cases, using the attribute shapes kosmos_strfry::approved_sync
|
||||
# reads (see site-cookbooks/strfry/attributes/default.rb for the production
|
||||
# config shape).
|
||||
cases = {
|
||||
'production relay config with explicit db_params' => Chef::Node::ImmutableMash.new(
|
||||
'strfry' => {
|
||||
'config' => {
|
||||
'db' => '/var/lib/strfry',
|
||||
'db_params' => {
|
||||
'maxreaders' => '2048',
|
||||
'mapsize' => '10995116277760',
|
||||
'no_read_ahead' => 'false'
|
||||
},
|
||||
'relay' => {
|
||||
'nofiles' => '524288'
|
||||
}
|
||||
}
|
||||
}
|
||||
),
|
||||
'production relay config with db_params absent (template fallbacks)' => Chef::Node::ImmutableMash.new(
|
||||
'strfry' => {
|
||||
'config' => {
|
||||
'db' => '/var/lib/strfry'
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
begin
|
||||
cases.each { |description, node| check_node(description, node) }
|
||||
puts "\nPASS: strfry_sync.conf.erb keeps a positive 100-year age floor."
|
||||
rescue StandardError => e
|
||||
warn "FAIL: #{e.message}"
|
||||
exit 1
|
||||
end
|
||||
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2024 Kosmos Developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,86 @@
|
||||
kosmos_strfry_submission
|
||||
========================
|
||||
|
||||
Installs and configures the **public submission relay** for Kosmos: a second,
|
||||
independent strfry instance that accepts *unreviewed* place photos (Nostr kind
|
||||
`360`, later `30360`) from anyone, on port `7778`, served publicly as
|
||||
`wss://submit.nostr.kosmos.org`.
|
||||
|
||||
It is intentionally **not** `kosmos_strfry` / `role[strfry]`:
|
||||
|
||||
* The openresty proxy builds its production `_strfry` upstream from nodes with
|
||||
`role[strfry]`. A submission node must never end up in that pool.
|
||||
* It has its own config, database, systemd unit and write policy.
|
||||
|
||||
## Recipes
|
||||
|
||||
| Recipe | Purpose |
|
||||
| --- | --- |
|
||||
| `default` | strfry binary (reused when `strfry::default` installed it), `/opt/strfry/submission-policy.mjs`, `/etc/strfry-submission.conf`, `strfry-submission.service` |
|
||||
| `firewall` | allow TCP `7778` from the openresty proxy nodes only (resolved via `search(:node, "role:openresty_proxy")`) |
|
||||
| `nginx` | runs on `role[openresty_proxy]`: TLS cert + `openresty_site` with its own `_strfry_submission` upstream |
|
||||
|
||||
## Attributes
|
||||
|
||||
| Attribute | Default | Notes |
|
||||
| --- | --- | --- |
|
||||
| `strfry_submission.domain` | `submit.nostr.kosmos.org` | public relay hostname |
|
||||
| `strfry_submission.port` | `7778` | strfry listen port |
|
||||
| `strfry_submission.config_file` | `/etc/strfry-submission.conf` | |
|
||||
| `strfry_submission.config.db` | `/var/lib/strfry-submission` | separate LMDB database |
|
||||
| `strfry_submission.config.db_params.mapsize` | `4 GiB` | hard cap; strfry has no prune |
|
||||
| `strfry_submission.config.relay.info.name` | `Kosmos submission relay` | NIP-11 name |
|
||||
| `strfry_submission.config.relay.write_policy.plugin` | `node /opt/strfry/submission-policy.mjs` | |
|
||||
| `strfry_submission.policy_url` | akkounts `extras/strfry/submission-policy.mjs` | fetched at converge |
|
||||
| `strfry_submission.policy_env` | `{}` | optional env for the policy |
|
||||
|
||||
The write policy itself lives in `kosmos/akkounts` (`extras/strfry/`) and is
|
||||
fetched at converge time, exactly like the production Deno policy. Its env var
|
||||
names are documented there.
|
||||
|
||||
## Firewall / exposure
|
||||
|
||||
Only the openresty proxy nodes (resolved from `role:openresty_proxy`) may reach
|
||||
`7778`. Public traffic arrives through nginx as
|
||||
`wss://submit.nostr.kosmos.org`, and the relay takes the client IP from nginx's
|
||||
`X-Real-IP` header (`relay.realIpHeader = "x-real-ip"`). Because that header is
|
||||
trusted, a virgo member that could connect to `:7778` directly could forge it
|
||||
and defeat the policy's **per-IP** token bucket — hence the narrow allow-list
|
||||
(the **per-author** bucket, keyed on `event.pubkey`, is unaffected either way).
|
||||
The member bridge on strfry-1 uses `ws://localhost:7778` (loopback) and is not
|
||||
affected by the allow-list.
|
||||
|
||||
Everything else on the host (production relay `7777`, blossom, substr) is
|
||||
unaffected.
|
||||
|
||||
## Node.js
|
||||
|
||||
The write policy is a plain Node ESM script and needs **Node 24 LTS**. Provision
|
||||
it via `role[strfry_submission]`, which sets a role-scoped
|
||||
`kosmos_nodejs.version` override. Do not raise the global default (14.21.3).
|
||||
|
||||
If this role is applied to a host that also runs blossom/substr (e.g. strfry-1),
|
||||
verify those services do not depend on Node 14 before converging — see
|
||||
`doc/nostr-submission-relay.md`.
|
||||
|
||||
## Deployment
|
||||
|
||||
1. DNS: `submit.nostr.kosmos.org` is a **CNAME to `lb.kosmos.org`** (the
|
||||
openresty proxy load balancer) at Gandi. **Chef does not manage DNS**, and the
|
||||
Let's Encrypt certificate cannot be issued without it. The CNAME is already in
|
||||
place; verify it resolves before converging the proxy nodes.
|
||||
2. Provision/assign `role[strfry_submission]` and converge the relay node.
|
||||
3. Converge the openresty proxy nodes (`role[openresty_proxy]`), which adds the
|
||||
`kosmos_strfry_submission::nginx` site.
|
||||
4. Verify: `curl -s -H 'Accept: application/nostr+json' https://submit.nostr.kosmos.org`
|
||||
returns the NIP-11 document with name `Kosmos submission relay` (without the
|
||||
`Accept` header strfry serves its HTML info page); `systemctl status
|
||||
strfry-submission`.
|
||||
|
||||
Rollback: remove `kosmos_strfry_submission::nginx` from the proxy run list,
|
||||
converge, and stop/disable `strfry-submission` on the relay node. The database
|
||||
lives in `/var/lib/strfry-submission` and can be deleted independently from the
|
||||
production relay.
|
||||
|
||||
This cookbook is deployed to production; see `doc/nostr-submission-relay.md`
|
||||
for the full runbook and rollback.
|
||||
@@ -0,0 +1,49 @@
|
||||
#
|
||||
# Cookbook Name:: kosmos_strfry_submission
|
||||
# Attributes:: default
|
||||
#
|
||||
|
||||
node.default["strfry_submission"]["domain"] = "submit.nostr.kosmos.org"
|
||||
node.default["strfry_submission"]["port"] = 7778
|
||||
node.default["strfry_submission"]["config_file"] = "/etc/strfry-submission.conf"
|
||||
|
||||
# Same directory as the production Deno policy: both live under /opt/strfry.
|
||||
node.default["strfry_submission"]["extras_dir"] = "/opt/strfry"
|
||||
|
||||
# Node write policy, fetched from kosmos/akkounts.
|
||||
node.default["strfry_submission"]["policy_url"] = "https://gitea.kosmos.org/kosmos/akkounts/raw/branch/live/extras/strfry/submission-policy.mjs"
|
||||
|
||||
# Extra environment variables for the write policy plugin (inherited from the
|
||||
# strfry process). Empty means "use the policy's built-in defaults".
|
||||
node.default["strfry_submission"]["policy_env"] = {}
|
||||
|
||||
node.default["strfry_submission"]["config"] = {
|
||||
db: "/var/lib/strfry-submission",
|
||||
db_params: {
|
||||
# This relay is a small, disposable landing area for *unreviewed* content,
|
||||
# so cap the LMDB map well below the production relay's 10 TB: a flood must
|
||||
# not be able to fill the disk (strfry has no prune).
|
||||
mapsize: 4 * 1024 * 1024 * 1024, # 4 GiB
|
||||
maxreaders: 128
|
||||
},
|
||||
events: {
|
||||
max_event_size: 65536
|
||||
},
|
||||
relay: {
|
||||
bind: "0.0.0.0",
|
||||
port: 7778,
|
||||
real_ip_header: "x-real-ip",
|
||||
info: {
|
||||
name: "Kosmos submission relay",
|
||||
description: "Public relay for submitted place photos. Content is reviewed before it is republished to nostr.kosmos.org.",
|
||||
contact: "ops@kosmos.org"
|
||||
},
|
||||
write_policy: {
|
||||
plugin: "node /opt/strfry/submission-policy.mjs",
|
||||
timeout_seconds: 10
|
||||
},
|
||||
logging: {
|
||||
invalid_events: true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
name 'kosmos_strfry_submission'
|
||||
maintainer 'Kosmos'
|
||||
maintainer_email 'ops@kosmos.org'
|
||||
license 'MIT'
|
||||
description 'Installs/configures the public nostr submission relay (a second strfry instance)'
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version '0.1.0'
|
||||
chef_version '>= 18.0'
|
||||
|
||||
depends 'firewall'
|
||||
depends 'kosmos-base'
|
||||
depends 'kosmos_openresty'
|
||||
depends 'strfry'
|
||||
@@ -0,0 +1,158 @@
|
||||
#
|
||||
# Cookbook Name:: kosmos_strfry_submission
|
||||
# Recipe:: default
|
||||
#
|
||||
# A second, independent strfry instance: the public submission relay
|
||||
# (submit.nostr.kosmos.org, port 7778). Writes are open to everyone and gated
|
||||
# only by the Node write policy in /opt/strfry/submission-policy.mjs.
|
||||
#
|
||||
# This recipe deliberately does NOT run strfry::default / role[strfry]: the
|
||||
# openresty proxy builds its production `_strfry` upstream from nodes with
|
||||
# role[strfry], and this relay must never end up in it.
|
||||
#
|
||||
|
||||
unless platform?("ubuntu")
|
||||
raise "This recipe only supports Ubuntu installs at the moment"
|
||||
end
|
||||
|
||||
extras_dir = node["strfry_submission"]["extras_dir"]
|
||||
config_file = node["strfry_submission"]["config_file"]
|
||||
db_dir = node["strfry_submission"]["config"]["db"]
|
||||
|
||||
#
|
||||
# Reuse the strfry binary that strfry::default installs on a shared host, and
|
||||
# install the same binary (same repo/revision/download_url attributes) when
|
||||
# this role owns a dedicated node. strfry::default stays the source of truth
|
||||
# for upgrades; we only fill the gap when the binary is not already present.
|
||||
#
|
||||
unless ::File.exist?("/usr/local/bin/strfry")
|
||||
if node["strfry"]["download_url"]
|
||||
remote_file "/usr/local/bin/strfry" do
|
||||
source node["strfry"]["download_url"]
|
||||
checksum node["strfry"]["checksum"]
|
||||
mode "0755"
|
||||
show_progress true
|
||||
notifies :restart, "service[strfry-submission]", :delayed
|
||||
end
|
||||
else
|
||||
%w[
|
||||
git build-essential libssl-dev zlib1g-dev liblmdb-dev libflatbuffers-dev
|
||||
libsecp256k1-dev libzstd-dev
|
||||
].each do |pkg|
|
||||
package pkg
|
||||
end
|
||||
|
||||
git "/usr/local/src/strfry" do
|
||||
repository node["strfry"]["repo"]
|
||||
revision node["strfry"]["revision"]
|
||||
enable_submodules true
|
||||
notifies :run, "execute[compile strfry]", :immediately
|
||||
end
|
||||
|
||||
execute "compile strfry" do
|
||||
cwd "/usr/local/src/strfry"
|
||||
command "make setup-golpe && make -j$(nproc)"
|
||||
action :nothing
|
||||
notifies :create, "link[/usr/local/bin/strfry]", :immediately
|
||||
notifies :restart, "service[strfry-submission]", :delayed
|
||||
end
|
||||
|
||||
link "/usr/local/bin/strfry" do
|
||||
to "/usr/local/src/strfry/strfry"
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
group node["strfry"]["group"]
|
||||
|
||||
user node["strfry"]["user"] do
|
||||
gid node["strfry"]["group"]
|
||||
manage_home true
|
||||
shell "/bin/bash"
|
||||
end
|
||||
|
||||
directory db_dir do
|
||||
owner node["strfry"]["user"]
|
||||
group node["strfry"]["group"]
|
||||
mode "0755"
|
||||
end
|
||||
|
||||
directory extras_dir do
|
||||
owner node["strfry"]["user"]
|
||||
group node["strfry"]["group"]
|
||||
mode "0755"
|
||||
end
|
||||
|
||||
#
|
||||
# Write policy (plain Node ESM, no dependencies), fetched from kosmos/akkounts
|
||||
# exactly like kosmos_strfry::policies fetches the production Deno policy.
|
||||
#
|
||||
remote_file "#{extras_dir}/submission-policy.mjs" do
|
||||
source node["strfry_submission"]["policy_url"]
|
||||
owner node["strfry"]["user"]
|
||||
group node["strfry"]["group"]
|
||||
mode "0755"
|
||||
notifies :restart, "service[strfry-submission]", :delayed
|
||||
end
|
||||
|
||||
#
|
||||
# Config. Rendered from the generic strfry config template so it always stays
|
||||
# in sync with the config options supported by the installed strfry.
|
||||
#
|
||||
template config_file do
|
||||
source "strfry.conf.erb"
|
||||
cookbook "strfry"
|
||||
owner node["strfry"]["user"]
|
||||
group node["strfry"]["group"]
|
||||
mode "0644"
|
||||
variables config: node["strfry_submission"]["config"]
|
||||
notifies :restart, "service[strfry-submission]", :delayed
|
||||
end
|
||||
|
||||
service "strfry-submission" do
|
||||
action :nothing
|
||||
end
|
||||
|
||||
service_settings = {
|
||||
Type: "simple",
|
||||
User: node["strfry"]["user"],
|
||||
Group: node["strfry"]["group"],
|
||||
ExecStart: "/usr/local/bin/strfry --config #{config_file} relay",
|
||||
Restart: "on-failure",
|
||||
RestartSec: "5",
|
||||
ProtectHome: "no",
|
||||
NoNewPrivileges: "yes",
|
||||
ProtectSystem: "full",
|
||||
LimitCORE: "1000000000",
|
||||
LimitNOFILE: "524288",
|
||||
# Best-effort caps so this open, potentially abused relay cannot starve the
|
||||
# production relay and blossom/substr that share the host.
|
||||
Nice: 10,
|
||||
MemoryHigh: "2G",
|
||||
MemoryMax: "3G"
|
||||
}
|
||||
|
||||
policy_env = node["strfry_submission"]["policy_env"] || {}
|
||||
unless policy_env.empty?
|
||||
service_settings[:Environment] = policy_env.map { |key, value| "#{key}=#{value}" }
|
||||
end
|
||||
|
||||
systemd_unit "strfry-submission.service" do
|
||||
content({
|
||||
Unit: {
|
||||
Description: "strfry public submission relay",
|
||||
Documentation: ["https://github.com/hoytech/strfry"]
|
||||
},
|
||||
Service: service_settings,
|
||||
Install: {
|
||||
WantedBy: "multi-user.target"
|
||||
}
|
||||
})
|
||||
triggers_reload true
|
||||
action :create
|
||||
end
|
||||
|
||||
service "strfry-submission" do
|
||||
action [:enable, :start]
|
||||
end
|
||||
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# Cookbook Name:: kosmos_strfry_submission
|
||||
# Recipe:: firewall
|
||||
#
|
||||
# Only the openresty proxy nodes may reach the relay directly. The relay trusts
|
||||
# the client IP from the `X-Real-IP` header (relay.realIpHeader = "x-real-ip"),
|
||||
# so any other virgo member with direct access to :7778 could forge that header
|
||||
# and defeat the per-IP token bucket in the write policy. (The per-author bucket
|
||||
# is keyed on event.pubkey and is unaffected.) Everything else must go through
|
||||
# nginx.
|
||||
#
|
||||
|
||||
include_recipe "kosmos-base::firewall"
|
||||
|
||||
relay_port = node["strfry_submission"]["port"]
|
||||
|
||||
proxy_hosts = search(:node, "role:openresty_proxy").map do |n|
|
||||
n["knife_zero"] && n["knife_zero"]["host"]
|
||||
end.compact.uniq.sort
|
||||
|
||||
if proxy_hosts.empty?
|
||||
Chef::Log.warn("No node found with 'openresty_proxy' role; not opening port #{relay_port}")
|
||||
else
|
||||
proxy_hosts.each do |host|
|
||||
firewall_rule "strfry-submission-#{host}" do
|
||||
port relay_port
|
||||
source host
|
||||
protocol :tcp
|
||||
command :allow
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,38 @@
|
||||
#
|
||||
# Cookbook Name:: kosmos_strfry_submission
|
||||
# Recipe:: nginx
|
||||
#
|
||||
# Reverse proxy for the public submission relay. Runs on the openresty proxy
|
||||
# nodes (role[openresty_proxy]) and uses its own `_strfry_submission` upstream,
|
||||
# so the submission relay is never mixed into the production `_strfry` pool.
|
||||
#
|
||||
# NOTE: submit.nostr.kosmos.org needs a manual A/AAAA record at Gandi that
|
||||
# points at the proxy node(s) before the Let's Encrypt certificate can be
|
||||
# issued. Chef does not manage DNS here.
|
||||
#
|
||||
|
||||
domain = node["strfry_submission"]["domain"]
|
||||
|
||||
upstream_hosts = []
|
||||
search(:node, "role:strfry_submission").each do |node|
|
||||
upstream_hosts << node["knife_zero"]["host"]
|
||||
end
|
||||
|
||||
if upstream_hosts.empty?
|
||||
Chef::Log.warn("No node found with 'strfry_submission' role. Not configuring nginx site.")
|
||||
return
|
||||
end
|
||||
|
||||
tls_cert_for domain do
|
||||
auth "gandi_dns"
|
||||
action :create
|
||||
end
|
||||
|
||||
openresty_site domain do
|
||||
template "nginx_conf_strfry_submission.erb"
|
||||
variables domain: domain,
|
||||
upstream_port: node["strfry_submission"]["port"],
|
||||
upstream_hosts: upstream_hosts,
|
||||
ssl_cert: "/etc/letsencrypt/live/#{domain}/fullchain.pem",
|
||||
ssl_key: "/etc/letsencrypt/live/#{domain}/privkey.pem"
|
||||
end
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
upstream _strfry_submission {
|
||||
<% @upstream_hosts.each do |host| %>
|
||||
server <%= host %>:<%= @upstream_port || "7778" %>;
|
||||
<% end %>
|
||||
}
|
||||
|
||||
server {
|
||||
server_name <%= @domain %>;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
|
||||
access_log "/var/log/nginx/<%= @domain %>.access.log";
|
||||
error_log "/var/log/nginx/<%= @domain %>.error.log";
|
||||
|
||||
ssl_certificate <%= @ssl_cert %>;
|
||||
ssl_certificate_key <%= @ssl_key %>;
|
||||
|
||||
location /metrics {
|
||||
return 404;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_pass http://_strfry_submission;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
server {
|
||||
server_name <%= @domain %>;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
|
||||
access_log <%= node[:openresty][:log_dir] %>/<%= @domain %>.access.log;
|
||||
error_log <%= node[:openresty][:log_dir] %>/<%= @domain %>.error.log warn;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
server {
|
||||
server_name <%= @domain %>;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
|
||||
root /var/www/<%= @domain %>/public;
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ server {
|
||||
|
||||
server {
|
||||
server_name <%= @domain %>;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2 default_server;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2 default_server;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl default_server;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl default_server;
|
||||
|
||||
if ($host != $server_name) {
|
||||
return 307 $scheme://$server_name;
|
||||
|
||||
@@ -9,3 +9,4 @@ chef_version '>= 14.0'
|
||||
|
||||
depends 'kosmos-base'
|
||||
depends 'zerotier'
|
||||
depends 'ohai'
|
||||
@@ -3,7 +3,20 @@
|
||||
# Recipe:: ohai_plugin
|
||||
#
|
||||
|
||||
include_recipe "zerotier::ohai_plugin"
|
||||
# Use our own copy of the community plugin template: the upstream one calls
|
||||
# File.exists?, which was removed in Ruby 3.4 (Cinc Client 19), making the
|
||||
# plugin fail and dropping the `zerotier` attribute from the node.
|
||||
ohai_plugin "zerotier_ohai" do
|
||||
compile_time false
|
||||
resource :template
|
||||
cookbook "kosmos_zerotier"
|
||||
source_file "zerotier_ohai.rb"
|
||||
variables(
|
||||
zerotier_binary: node["zerotier"]["binary"],
|
||||
control_port: node["zerotier"]["control_port"],
|
||||
data_dir: node["zerotier"]["data_dir"]
|
||||
)
|
||||
end
|
||||
|
||||
ohai "reload_zerotier" do
|
||||
action :reload
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
|
||||
Ohai.plugin(:ZeroTier) do
|
||||
provides 'zerotier'
|
||||
|
||||
def zerotier_command (subcommand)
|
||||
return "<%= @zerotier_binary %> <% unless @zerotier_binary.end_with?('-cli') %>-q<% end %> #{subcommand} -p<%= @control_port %> -D<%= @data_dir %>"
|
||||
end
|
||||
|
||||
def linux_get_networks
|
||||
networks = Mash.new
|
||||
cmd = zerotier_command('listnetworks')
|
||||
Ohai::Log.info(cmd)
|
||||
so = shell_out(cmd)
|
||||
first_line = true
|
||||
so.stdout.lines do |line|
|
||||
if first_line
|
||||
# skip the header line
|
||||
first_line = false
|
||||
next
|
||||
end
|
||||
|
||||
data = line.strip.split(/\s+/)
|
||||
|
||||
cur_network = Mash.new
|
||||
cur_network[:network_name] = data[3]
|
||||
cur_network[:mac] = data[4]
|
||||
cur_network[:status] = data[5]
|
||||
cur_network[:type] = data[6]
|
||||
cur_network[:interface] = data[7]
|
||||
cur_network[:addresses] = []
|
||||
|
||||
data[8].split(',').each do |addr|
|
||||
cur_network[:addresses].push(addr)
|
||||
end
|
||||
|
||||
networks[data[2]] = cur_network
|
||||
end
|
||||
return networks
|
||||
end
|
||||
|
||||
def linux_get_node_id
|
||||
node_id = ''
|
||||
|
||||
# File.exists? was removed in Ruby 3.4, use File.exist?
|
||||
if ::File.exist?("<%= @data_dir %>/identity.public")
|
||||
node_id = ::File.read("<%= @data_dir %>/identity.public")
|
||||
node_id = node_id[0..9]
|
||||
Ohai
|
||||
else
|
||||
Ohai::Log.warn("<%= @data_dir %>/identity.public' does not exist")
|
||||
end
|
||||
|
||||
return node_id unless node_id.empty?
|
||||
end
|
||||
|
||||
def get_version
|
||||
so = shell_out("<%= @zerotier_binary %> -v 2>&1")
|
||||
version = so.stdout.strip
|
||||
return version unless version.empty?
|
||||
end
|
||||
|
||||
collect_data(:linux) do
|
||||
# File.exists? was removed in Ruby 3.4, use File.exist?
|
||||
if ::File.exist?("<%= @zerotier_binary %>")
|
||||
zerotier Mash.new
|
||||
zerotier[:version] = get_version
|
||||
zerotier[:node_id] = linux_get_node_id
|
||||
zerotier[:networks] = linux_get_networks
|
||||
else
|
||||
Ohai::Log.warn("Cannot find zerotier binary")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -4,8 +4,8 @@ upstream _kredits_github {
|
||||
|
||||
server {
|
||||
server_name <%= @domain %>;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
|
||||
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl;
|
||||
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl;
|
||||
|
||||
access_log "<%= node['openresty']['log_dir'] %>/<%= @domain %>.access.log" json;
|
||||
error_log "<%= node['openresty']['log_dir'] %>/<%= @domain %>.error.log";
|
||||
|
||||
@@ -2,6 +2,20 @@
|
||||
|
||||
This file is used to list changes made in each version of the liquor_cabinet cookbook.
|
||||
|
||||
## 0.4.0
|
||||
|
||||
- Preload jemalloc into the Rainbows master and workers (`LD_PRELOAD` on the
|
||||
`liquor-cabinet.service` unit) to reduce heap fragmentation and growth.
|
||||
- Restart the service when the systemd unit changes, so the new environment
|
||||
actually takes effect (`systemd_unit` only reloads the daemon).
|
||||
|
||||
## 0.3.0
|
||||
|
||||
- Pin Liquor Cabinet to the 2.0.0-rc.2 release.
|
||||
- Enable hashed remoteStorage access token lookup (`hashed_access_tokens`),
|
||||
so authorizations are read by the SHA256 digest of the bearer token, with
|
||||
the plaintext key kept as a fallback.
|
||||
|
||||
## 0.2.0
|
||||
|
||||
- Add Redis password support.
|
||||
|
||||
Loaded 100 of 115 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user