Merge pull request 'DEPLOY: one-time sudo delegation for kartsell restart' (#13) from fix/deploy-kartsell-nopasswd into main
ci / static (push) Has been cancelled
ci / backend (push) Has been cancelled
ci / frontend (push) Has been cancelled
ci / publish (push) Has been cancelled
Build & Test with Secrets / build (push) Has been cancelled
Build & Test with Secrets / frontend (push) Has been cancelled
Build & Test with Secrets / security-scan (push) Has been cancelled
Build & Test with Secrets / notification (push) Has been cancelled
deploy / deploy (push) Successful in 2m35s
deploy / notify (push) Successful in 1s
ci / static (push) Has been cancelled
ci / backend (push) Has been cancelled
ci / frontend (push) Has been cancelled
ci / publish (push) Has been cancelled
Build & Test with Secrets / build (push) Has been cancelled
Build & Test with Secrets / frontend (push) Has been cancelled
Build & Test with Secrets / security-scan (push) Has been cancelled
Build & Test with Secrets / notification (push) Has been cancelled
deploy / deploy (push) Successful in 2m35s
deploy / notify (push) Successful in 1s
Reviewed-on: #13
This commit was merged in pull request #13.
This commit is contained in:
@@ -58,6 +58,11 @@ jobs:
|
||||
echo ""
|
||||
ssh -i /tmp/deploy_key.pem -o StrictHostKeyChecking=no kjh2064@178.104.200.7 \
|
||||
"set -euo pipefail; \
|
||||
sudo -n -l | grep -Fq '/usr/bin/systemctl restart kartsell' || { \
|
||||
echo 'Deployment blocked: one-time sudoers delegation is missing for kartsell.' >&2; \
|
||||
echo 'Expected: kjh2064 ALL=(root) NOPASSWD: /usr/bin/systemctl restart kartsell' >&2; \
|
||||
exit 77; \
|
||||
}; \
|
||||
export KARTSELL_POSTGRES='${{ secrets.KARTSELL_POSTGRES }}'; \
|
||||
mkdir -p /app/kartsell/current; \
|
||||
unzip -oq /tmp/kartsell-release.zip -d /app/kartsell/current; \
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
# KArtSell 배포 재기동 권한 계약
|
||||
|
||||
## Source
|
||||
|
||||
- 운영 호스트 `hz-prod-01`의 실제 sudo 정책 조회 결과
|
||||
- 기존 `quantengine` 및 `taxbaik` 서비스의 특정 `systemctl restart` `NOPASSWD` 위임 패턴
|
||||
- `.gitea/workflows/deploy.yml`
|
||||
|
||||
## Assumption
|
||||
|
||||
- 배포 SSH 계정은 `kjh2064`로 유지한다.
|
||||
- 운영 서비스는 `/etc/systemd/system/kartsell.service`로 유지한다.
|
||||
- DbMigrator와 artifact 복사는 현재처럼 `kjh2064` 권한으로 수행한다.
|
||||
|
||||
## Decision
|
||||
|
||||
`kjh2064`에 전체 sudo 권한을 부여하지 않고, 운영자가 한 번만 다음 단일 명령을 `/etc/sudoers.d/kartsell-deploy`에 등록한다.
|
||||
|
||||
```sudoers
|
||||
kjh2064 ALL=(root) NOPASSWD: /usr/bin/systemctl restart kartsell
|
||||
```
|
||||
|
||||
파일 권한은 `0440`이어야 하며 `visudo -cf /etc/sudoers.d/kartsell-deploy` 검증 후 적용한다. 이후 CI는 비대화형 `sudo -n systemctl restart kartsell`만 사용하므로 배포마다 비밀번호 입력이나 sudo 등록이 필요 없다.
|
||||
|
||||
## Deployment guard
|
||||
|
||||
워크플로우는 artifact 복사와 DbMigrator 실행 전에 `sudo -n -l`로 위임 존재 여부를 검사한다. 위임이 없으면 운영 DB를 변경하지 않고 exit 77로 종료한다.
|
||||
|
||||
## Unknown / Decision Required
|
||||
|
||||
- 이 파일을 운영 호스트에 설치할 권한은 root 운영자에게만 있다.
|
||||
- 설치 후 필요한 증거: `visudo -cf` 결과, `sudo -n -l` 결과, 다음 deploy run의 성공 로그, 서비스 active 상태.
|
||||
Reference in New Issue
Block a user