Let GRAYLOG_ADMIN_PASSWORD pin a custom password, add cores input to CI
- step_compose_files() now uses GRAYLOG_ADMIN_PASSWORD as the actual admin password on a fresh install if set, instead of always generating a random one. Solves the CI secret-staleness problem at the root: pin a password once and it's correct both at creation time and on every later re-run, instead of a fresh install randomly generating a password the stored secret then has to be manually kept in sync with. - deploy-from-scratch.yml gained a `cores` workflow_dispatch input (default 4), passed through to create-graylog-lxc.sh's --cores flag. Only takes effect when the container is actually created fresh, same as every other --cores usage in this project. - Documented both in README.md/README.uk.md. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
ab3f560d4a
commit
eb6225f2f8
4 changed files with 73 additions and 12 deletions
|
|
@ -1,6 +1,11 @@
|
|||
name: Deploy Graylog from scratch (host-level)
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
cores:
|
||||
description: 'CPU cores for the container (only takes effect when creating it fresh - a no-op on an already-existing container)'
|
||||
required: false
|
||||
default: '4'
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
|
|
@ -26,6 +31,7 @@ jobs:
|
|||
# Graylog dies at resolve_admin_password with "Cannot find admin
|
||||
# password" - confirmed live.
|
||||
GRAYLOG_ADMIN_PASSWORD: ${{ secrets.GRAYLOG_ADMIN_PASSWORD }}
|
||||
CORES: ${{ inputs.cores }}
|
||||
run: |
|
||||
rm -rf /tmp/graylog-deploy-ci-host
|
||||
git clone --depth 1 --branch main "https://x-access-token:${CI_TOKEN}@git.zotac.keenetic.link/zotac/graylog-deploy.git" /tmp/graylog-deploy-ci-host
|
||||
|
|
@ -37,6 +43,7 @@ jobs:
|
|||
--gw 10.254.254.235 \
|
||||
--vlan 1254 \
|
||||
--disk 50 \
|
||||
--cores "$CORES" \
|
||||
--template-storage local-btrfs \
|
||||
--rootfs-storage EX-Ceph \
|
||||
--external-uri http://93.171.241.5:9000/ \
|
||||
|
|
|
|||
30
README.md
30
README.md
|
|
@ -611,7 +611,11 @@ never created), when you'd rather click a button than type the full
|
|||
`create-graylog-lxc.sh` invocation.
|
||||
|
||||
**Running it:** repo → **Actions** tab → **Deploy Graylog from scratch
|
||||
(host-level)** in the left sidebar → **Run workflow** button → confirm.
|
||||
(host-level)** in the left sidebar → **Run workflow** button → a `cores`
|
||||
field appears (default `4`) - override it or leave as-is → confirm. Only
|
||||
takes effect when the container is actually being created fresh; a no-op
|
||||
on one that already exists (same rule as the `--cores` flag everywhere
|
||||
else in this project - see "Parameters" above).
|
||||
|
||||
- **The runner lives on the Proxmox host itself**, running as
|
||||
`claude-deploy` (not root - see step 9b above for why that matters),
|
||||
|
|
@ -694,8 +698,8 @@ Inside the container, everything lives under `/opt/graylog/`
|
|||
|
||||
## Credentials
|
||||
|
||||
`install-graylog.sh` generates `GRAYLOG_PASSWORD_SECRET` and a random
|
||||
admin password on first run, writing the admin password once to
|
||||
`install-graylog.sh` generates `GRAYLOG_PASSWORD_SECRET` and an admin
|
||||
password on first run, writing the admin password once to
|
||||
`/opt/graylog/.admin_credentials_ONE_TIME` inside the container. The
|
||||
script itself prints it and deletes the file automatically at the end of
|
||||
a successful run - store it in your password manager then. If the run
|
||||
|
|
@ -704,3 +708,23 @@ died before reaching that point, read and remove the file by hand:
|
|||
pct exec <VMID> -- cat /opt/graylog/.admin_credentials_ONE_TIME
|
||||
pct exec <VMID> -- rm /opt/graylog/.admin_credentials_ONE_TIME
|
||||
```
|
||||
|
||||
**The admin password itself** is random by default, but `GRAYLOG_ADMIN_PASSWORD`
|
||||
(env var, same one `create-graylog-lxc.sh` forwards through) can pin it to
|
||||
a known value instead - set on a fresh install, that value becomes the
|
||||
actual password, not just a fallback. Two different roles for the same
|
||||
variable depending on when it's set:
|
||||
- **On a fresh install** (`.env` doesn't exist yet): if set, becomes the
|
||||
real password instead of a random one. If unset, random as before.
|
||||
- **On any later re-run** (`.env` already exists, one-time file already
|
||||
consumed by an earlier successful run): required, must match whatever
|
||||
password is already configured - there's no other way for the script to
|
||||
authenticate to the running instance.
|
||||
|
||||
This matters most for CI: pin a password once via the `GRAYLOG_ADMIN_PASSWORD`
|
||||
Forgejo secret, and it never goes stale - the same value is correct at
|
||||
creation time and on every re-run after, instead of having to notice a
|
||||
fresh install generated a new random password and update the secret to
|
||||
match (confirmed live: a `deploy-from-scratch.yml` re-run against an
|
||||
already-initialized Graylog with a stale secret died at
|
||||
`resolve_admin_password` with "Cannot find admin password").
|
||||
|
|
|
|||
41
README.uk.md
41
README.uk.md
|
|
@ -630,8 +630,11 @@ pipeline на вже існуючий контейнер.
|
|||
кнопку замість вводу повної команди `create-graylog-lxc.sh`.
|
||||
|
||||
**Як запускати:** репо → вкладка **Actions** → **Deploy Graylog from
|
||||
scratch (host-level)** у лівому меню → кнопка **Run workflow** →
|
||||
підтвердити.
|
||||
scratch (host-level)** у лівому меню → кнопка **Run workflow** → з'явиться
|
||||
поле `cores` (за замовчуванням `4`) — змініть або лишіть як є →
|
||||
підтвердити. Спрацьовує лише коли контейнер реально створюється заново;
|
||||
на вже існуючому — no-op (те саме правило, що й для `--cores` всюди в
|
||||
цьому проєкті — див. "Параметри" вище).
|
||||
|
||||
- **Раннер живе прямо на хості Proxmox**, працює від `claude-deploy`
|
||||
(не root — див. крок 9b вище, чому це важливо), зареєстрований з
|
||||
|
|
@ -713,14 +716,36 @@ dashboards/view_*.json # макет дашборду/віджетів Vi
|
|||
|
||||
## Креденшели
|
||||
|
||||
`install-graylog.sh` генерує `GRAYLOG_PASSWORD_SECRET` та випадковий
|
||||
пароль адміністратора під час першого запуску, одноразово записуючи
|
||||
пароль адміністратора у `/opt/graylog/.admin_credentials_ONE_TIME`
|
||||
всередині контейнера. Сам скрипт виводить його і автоматично видаляє
|
||||
файл наприкінці успішного прогону — збережіть пароль у менеджері паролів
|
||||
тоді ж. Якщо прогін впав раніше цього моменту, прочитайте й видаліть файл
|
||||
`install-graylog.sh` генерує `GRAYLOG_PASSWORD_SECRET` та пароль
|
||||
адміністратора під час першого запуску, одноразово записуючи пароль
|
||||
адміністратора у `/opt/graylog/.admin_credentials_ONE_TIME` всередині
|
||||
контейнера. Сам скрипт виводить його і автоматично видаляє файл
|
||||
наприкінці успішного прогону — збережіть пароль у менеджері паролів тоді
|
||||
ж. Якщо прогін впав раніше цього моменту, прочитайте й видаліть файл
|
||||
вручну:
|
||||
```bash
|
||||
pct exec <VMID> -- cat /opt/graylog/.admin_credentials_ONE_TIME
|
||||
pct exec <VMID> -- rm /opt/graylog/.admin_credentials_ONE_TIME
|
||||
```
|
||||
|
||||
**Сам пароль адміністратора** за замовчуванням випадковий, але
|
||||
`GRAYLOG_ADMIN_PASSWORD` (змінна середовища, та сама, яку прокидує
|
||||
`create-graylog-lxc.sh`) може зафіксувати його на відоме значення замість
|
||||
випадкового — заданий при свіжому встановленні, він стає справжнім
|
||||
паролем, а не лише резервним значенням. Дві різні ролі однієї змінної
|
||||
залежно від того, коли вона задана:
|
||||
- **При свіжому встановленні** (`.env` ще не існує): якщо задано — стає
|
||||
реальним паролем замість випадкового. Якщо ні — випадковий, як і раніше.
|
||||
- **При будь-якому подальшому повторному запуску** (`.env` вже існує,
|
||||
одноразовий файл уже спожитий попереднім успішним прогоном):
|
||||
обов'язково, має збігатися з паролем, який уже налаштований — інакше
|
||||
скрипту нема як автентифікуватись до вже запущеного інстансу.
|
||||
|
||||
Це найважливіше саме для CI: зафіксуйте пароль один раз через Forgejo
|
||||
секрет `GRAYLOG_ADMIN_PASSWORD`, і він ніколи не застаріє — те саме
|
||||
значення правильне і при створенні, і при кожному подальшому повторному
|
||||
запуску, замість того, щоб помічати, що свіже встановлення згенерувало
|
||||
новий випадковий пароль, і оновлювати секрет вручну (перевірено наживо:
|
||||
повторний запуск `deploy-from-scratch.yml` проти вже ініціалізованого
|
||||
Graylog зі застарілим секретом падав на `resolve_admin_password` з
|
||||
"Cannot find admin password").
|
||||
|
|
|
|||
|
|
@ -127,7 +127,12 @@ step_compose_files() {
|
|||
log "Generating fresh secrets into $INSTALL_DIR/.env ..."
|
||||
local secret admin_pass admin_sha2
|
||||
secret="$(openssl rand -hex 48)"
|
||||
admin_pass="$(openssl rand -base64 18 | tr -dc 'A-Za-z0-9' | head -c20)"
|
||||
# GRAYLOG_ADMIN_PASSWORD lets the operator pin a known password up front
|
||||
# instead of always getting a random one - useful for CI, where it means
|
||||
# the Forgejo secret is set once and never goes stale, rather than having
|
||||
# to be re-synced every time a fresh install randomly generates a new
|
||||
# password. Falls back to random if not set, same as before.
|
||||
admin_pass="${GRAYLOG_ADMIN_PASSWORD:-$(openssl rand -base64 18 | tr -dc 'A-Za-z0-9' | head -c20)}"
|
||||
admin_sha2="$(echo -n "$admin_pass" | sha256sum | cut -d' ' -f1)"
|
||||
|
||||
cat > "$INSTALL_DIR/.env" <<EOF
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue