Merge remote-tracking branch 'origin/master' into chore/upgrade_gitea-runner
# Conflicts: # site-cookbooks/kosmos_gitea/CHANGELOG.md # site-cookbooks/kosmos_gitea/metadata.rb
This commit is contained in:
81 files changed
+1719
-134
No files matched your search
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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`).
|
||||
@@ -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: 1aee118742...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
|
||||
|
||||
@@ -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
|
||||
)
|
||||
@@ -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 %>;
|
||||
|
||||
@@ -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 -%>
|
||||
|
||||
@@ -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 -%>
|
||||
|
||||
@@ -19,7 +19,7 @@ node.default["kosmos-mastodon"]["build"] = true
|
||||
|
||||
# Runtime versions
|
||||
node.default["kosmos-mastodon"]["nodejs_version"] = "24.22.1"
|
||||
node.default["kosmos-mastodon"]["ruby_version"] = "4.0.9"
|
||||
node.default["kosmos-mastodon"]["ruby_version"] = "4.0.10"
|
||||
node.default["kosmos-mastodon"]["ruby_build_version"] = "v20261023"
|
||||
|
||||
# SSH deploy key access to the (private) repository. The private key is stored
|
||||
|
||||
@@ -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 %>;
|
||||
|
||||
@@ -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,7 +2,7 @@
|
||||
|
||||
This file is used to list changes made in each version of the kosmos_gitea cookbook.
|
||||
|
||||
# 0.3.8
|
||||
# 0.3.10
|
||||
|
||||
- Upgrade Gitea from 28.3.0 to 28.4.0. This is a maintenance release with no
|
||||
breaking changes and no `app.ini` changes; no configuration updates were
|
||||
@@ -32,6 +32,30 @@ This file is used to list changes made in each version of the kosmos_gitea cookb
|
||||
step ends, Docker actions join the job network, pinned action SHAs are
|
||||
verified, and several artifact/cache/composite-action bugs are fixed.
|
||||
|
||||
# 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
|
||||
|
||||
@@ -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.8'
|
||||
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
|
||||
|
||||
@@ -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: /
|
||||
@@ -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;
|
||||
|
||||
@@ -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.4~#{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'
|
||||
}
|
||||
@@ -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.4~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,13 @@
|
||||
|
||||
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.
|
||||
|
||||
@@ -3,7 +3,7 @@ maintainer 'Kosmos Developers'
|
||||
maintainer_email 'ops@kosmos.org'
|
||||
license 'MIT'
|
||||
description 'Installs/configures the Liquor Cabinet remoteStorage API server'
|
||||
version '0.3.0'
|
||||
version '0.4.0'
|
||||
chef_version '>= 18.2'
|
||||
issues_url 'https://gitea.kosmos.org/kosmos/chef/issues'
|
||||
# source_url 'https://gitea.kosmos.org/kosmos/chef'
|
||||
|
||||
@@ -104,6 +104,9 @@ template "/etc/rainbows/#{app_name}.rb" do
|
||||
notifies :restart, "service[#{app_name}]", :delayed
|
||||
end
|
||||
|
||||
# jemalloc for the Rainbows workers (referenced by LD_PRELOAD in the unit below)
|
||||
package 'libjemalloc2'
|
||||
|
||||
systemd_unit "#{app_name}.service" do
|
||||
content({
|
||||
Unit: {
|
||||
@@ -115,7 +118,12 @@ systemd_unit "#{app_name}.service" do
|
||||
Type: "simple",
|
||||
User: deploy_user,
|
||||
WorkingDirectory: deploy_path,
|
||||
Environment: "RACK_ENV=#{rack_env}",
|
||||
Environment: [
|
||||
"RACK_ENV=#{rack_env}",
|
||||
# jemalloc keeps the long-lived Rainbows workers from fragmenting/
|
||||
# retaining heap the way glibc malloc does.
|
||||
"LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2"
|
||||
],
|
||||
ExecStart: "#{bundle_path} exec rainbows -c /etc/rainbows/#{app_name}.rb -E #{rack_env}",
|
||||
PIDFile: "#{deploy_path}/tmp/rainbows.pid",
|
||||
TimeoutSec: "10",
|
||||
@@ -130,8 +138,12 @@ systemd_unit "#{app_name}.service" do
|
||||
action [:create, :enable]
|
||||
end
|
||||
|
||||
# `systemd_unit` only reloads the daemon and never restarts a running unit, so
|
||||
# unit/env changes would not take effect until the next repo change or reboot.
|
||||
# Restart whenever the unit file changes (e.g. to pick up LD_PRELOAD).
|
||||
service app_name do
|
||||
action [:enable, :start]
|
||||
subscribes :restart, "systemd_unit[#{app_name}.service]", :delayed
|
||||
end
|
||||
|
||||
if node[app_name]['ufw_source_allowed']
|
||||
|
||||
+1
-1
Submodule site-cookbooks/openresty updated: 22f3aa1918...223c5e9bd9.
@@ -7,8 +7,8 @@ upstream _rs_discourse {
|
||||
|
||||
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,6 +1,11 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
0.5.0
|
||||
-----
|
||||
- Update to sockethub 5.0.0-beta.2
|
||||
- Enable the `@sockethub/platform-email` platform
|
||||
|
||||
0.4.0
|
||||
-----
|
||||
- Update to sockethub 5.0.0-beta.0
|
||||
|
||||
@@ -10,7 +10,7 @@ Attributes
|
||||
|
||||
| Key | Type | Description | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| `['sockethub']['version']` | String | The npm version of sockethub to install | `5.0.0-beta.0` |
|
||||
| `['sockethub']['version']` | String | The npm version of sockethub to install | `5.0.0-beta.2` |
|
||||
| `['sockethub']['port']` | Integer | The local port to run sockethub on | `10550` |
|
||||
| `['sockethub']['domain']` | String | The public domain served by the openresty proxy | `sockethub.kosmos.org` |
|
||||
| `['sockethub']['log_level']` | String | Console log level (error, warn, info, debug) | `info` |
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
node.default['sockethub']['version'] = '5.0.0-beta.0'
|
||||
node.default['sockethub']['version'] = '5.0.0-beta.2'
|
||||
node.default['sockethub']['port'] = '10550'
|
||||
node.default['sockethub']['domain'] = 'sockethub.kosmos.org'
|
||||
node.default['sockethub']['log_level'] = 'info'
|
||||
@@ -15,6 +15,7 @@ node.default['sockethub']['about'] = {
|
||||
node.default['sockethub']['platforms'] = [
|
||||
'@sockethub/platform-carddav',
|
||||
'@sockethub/platform-caldav',
|
||||
'@sockethub/platform-email',
|
||||
'@sockethub/platform-feeds',
|
||||
'@sockethub/platform-irc',
|
||||
'@sockethub/platform-metadata',
|
||||
|
||||
@@ -4,7 +4,7 @@ maintainer_email 'mail@kosmos.org'
|
||||
license 'MIT'
|
||||
description 'Installs/Configures sockethub'
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version '0.4.0'
|
||||
version '0.5.0'
|
||||
|
||||
depends 'firewall'
|
||||
depends 'kosmos-base'
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# Recipe:: default
|
||||
#
|
||||
|
||||
node.override["kosmos_nodejs"]["version"] = "24.22.1"
|
||||
node.override["kosmos_nodejs"]["version"] = "24.22.2"
|
||||
include_recipe 'kosmos-nodejs'
|
||||
|
||||
user = "sockethub"
|
||||
|
||||
@@ -9,8 +9,8 @@ map $http_upgrade $connection_upgrade {
|
||||
|
||||
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";
|
||||
|
||||
Reference in new issue
Block a user