Усиление контейнеров и проверка отказоустойчивости

This commit is contained in:
EgorAnti
2026-11-26 17:26:19 +03:00
parent d23847f953
commit 60fa12ce6e
24 changed files with 418 additions and 68 deletions
+5 -2
View File
@@ -2,12 +2,15 @@
param([string]$EnvFile = '.env')
$ErrorActionPreference = 'Stop'
Set-Location (Join-Path $PSScriptRoot '..')
$projectRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
Set-Location $projectRoot
if ([string]::IsNullOrWhiteSpace($env:BAO_TOKEN)) { throw 'Set BAO_TOKEN for this operator action.' }
foreach($role in 'api','worker') {
$roleName = "messenger-$role"
$directory = Join-Path $projectRoot "secrets\openbao\$role"
New-Item -ItemType Directory -Path $directory -Force | Out-Null
$secretId = (& docker compose --env-file $EnvFile exec -T -e "BAO_TOKEN=$env:BAO_TOKEN" openbao bao write -field=secret_id -f "auth/approle/role/$roleName/secret-id" | Out-String).Trim()
if($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($secretId)){ throw "Failed to rotate $roleName SecretID" }
[System.IO.File]::WriteAllText((Join-Path "secrets\openbao\$role" 'secret-id'),$secretId,[System.Text.Encoding]::ASCII)
[System.IO.File]::WriteAllText((Join-Path $directory 'secret-id'),$secretId,[System.Text.Encoding]::ASCII)
}
Write-Host 'AppRole SecretIDs rotated without printing their values.'