Interview Prep/Ansible/Security and Secrets

How do you rotate secrets such as database passwords or API keys with Ansible?

IntermediateProductionSecurity and Secrets
Answer

Orchestrate in the right order so there is no outage: generate the new value, update the source of truth (secret manager), apply it to the consumer (the database user, then app config), reload, verify health, and only then retire the old value.

For database accounts, support two valid credentials during the changeover, or rotate in a rolling manner with serial. Keep the rotation playbook idempotent and tagged (--tags rotate_db), and log each step without printing the secret (no_log). If a manager can rotate by itself (Secrets Manager rotation Lambda), let Ansible only consume the value.

All Ansible questions Roadmap: Ansible

More on Security and Secrets