forked from mtusi2026/mtusi2026lab7
Усиление контейнеров и проверка отказоустойчивости
This commit is contained in:
@@ -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.'
|
||||
|
||||
Reference in New Issue
Block a user