Add aap_secret_rotate role for SECRET_KEY rotation across AAP 2.7 components - #380
Open
amasolov wants to merge 3 commits into
Open
Add aap_secret_rotate role for SECRET_KEY rotation across AAP 2.7 components#380amasolov wants to merge 3 commits into
amasolov wants to merge 3 commits into
Conversation
amasolov
force-pushed
the
feat/aap-secret-rotate
branch
from
August 17, 2026 08:37
c7317ab to
a709b5a
Compare
…ponents New role that automates the rotation of database encryption keys (SECRET_KEY) for Controller, Gateway, EDA, and Hub on both Podman and Operator deployments. Features: - Full 4-component rotation with proper ordering (Gateway last) - Podman: stop/start containers, replace podman secrets, update in-container files - Operator: idle AAP CR, exec into pods, patch K8s Secrets, rollout restart - Kubernetes-agnostic (works on OpenShift, AKS, EKS, vanilla K8s) - Auto-detection of ESO and ArgoCD with pause/resume support - Pre/post-flight verification of all encrypted database fields - Custom key support and auto-generated Fernet-compatible keys - Dry-run mode for safe previewing - Hub multi-key file handling for zero-downtime rotation - AuthenticatorUser.extra_data workaround for upstream Gateway bug Tested end-to-end on: - AAP 2.7.4 operator deployment (OpenShift, 3 consecutive runs) - AAP 2.7 containerised installer (Podman on RHEL 9.6, AWS EC2) - Both operator-managed and external (CNPG) PostgreSQL databases Also adds containers.podman collection dependency to galaxy.yml. Co-authored-by: Cursor <cursoragent@cursor.com>
amasolov
force-pushed
the
feat/aap-secret-rotate
branch
from
August 19, 2026 23:38
a709b5a to
9ec9006
Compare
9 tasks
PR Review:
|
| Component | Command | Key Env Var |
|---|---|---|
| Controller | awx-manage regenerate_secret_key --use-custom-key |
TOWER_SECRET_KEY |
| Gateway | aap-gateway-manage rotate_secret_key --use-custom-key |
GATEWAY_SECRET_KEY |
| EDA | aap-eda-manage rotate_db_encryption_key --use-custom-key |
EDA_DB_ROTATION_KEY |
| Hub | pulpcore-manager rotate-db-key |
Multi-key file |
Strengths
- Pre/post-flight checks — verifies all encrypted fields are decryptable before AND after rotation
- Hub multi-key support — zero-downtime rotation (old+new keys during migration phase)
- Gateway bug workaround — clears
AuthenticatorUser.extra_databefore rotation (upstream fix pending) - ESO/ArgoCD detection — auto-pauses GitOps during rotation, with configurable resume
- Fernet key generation — auto-generates valid keys if not provided
- Dry-run mode — safe preview before changes
Combination with PR #384 (aap_password_rotate)
These roles are completely independent — no technical dependency between them:
| Role | What It Rotates | Scope |
|---|---|---|
aap_secret_rotate (this PR) |
SECRET_KEY | Encryption keys for data AT REST |
aap_password_rotate (#384) |
DB passwords | Authentication TO PostgreSQL |
Safe to use independently or together. If running both in same maintenance window:
- Complete one fully before starting the other
- Recommended order: password rotation first, then secret rotation (stable DB connectivity aids recovery if secret rotation fails)
No Issues Found
Role is well-designed with comprehensive safety checks.
Review performed alongside PR #384 to verify independence and combined usage safety.
Add major_changes changelog fragment for the new aap_secret_rotate role. Co-authored-by: Cursor <cursoragent@cursor.com>
Author
|
@branic Thanks for looking into this, I've added changelog fragmenets to both |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds a new
aap_secret_rotaterole that automates the rotation of database encryption keys (SECRET_KEY) for all AAP 2.7 components: Controller, Gateway, EDA, and Hub.Supports both deployment types:
podman exec, replaces podman secrets (including in-container file updates), restarts servicesKey features:
AuthenticatorUser.extra_datarecords cause decryption failures duringrotate_secret_key(records are cleared before rotation and auto-recreated on next user login)EDA_SECRET_KEY)containers.podmancollection dependency togalaxy.ymlHow should this be tested?
Dry run (safe, read-only)
Full rotation (podman)
Full rotation (operator)
Verification after rotation:
awx-manage shell -c "...")E2E test results:
Is there a relevant Issue open for this?
No existing issue. This addresses a common Day 2 operations requirement for AAP deployments where periodic SECRET_KEY rotation is needed for security compliance.
Other Relevant info, PRs, etc
rotate_secret_keycommand: Shipped in AAP 2.7.4+ (upstream: ansible/jewel#52, Jira: AAP-75712). The role dynamically detects its presence and skips Gateway rotation with a warning on older builds.AuthenticatorUser.extra_databug: Therotate_secret_keycommand readsAuthenticatorUser.extra_datavia raw SQL without deserialising the jsonb wrapper, causing spurious decryption failures. The upstream fix has been merged and will be backported and released soon. Until then, this role includes a workaround (clearing the records before rotation; they are auto-recreated on next user login).