Database passwords are sitting in plain text in `group_vars`. How do you fix it?
BeginnerScenarioSecurity: Vault, Become and Compliance
Answer
Situation read → Secrets in Git.
What I'd do →
- Encrypt the file:
ansible-vault encrypt group_vars/prod/vault.yml. - Keep a plain
vars.ymlthat referencesvault_variables. - Pass the password via
--vault-password-fileor--vault-id. - Rotate any password that was ever committed in plain text.
# group_vars/prod/vars.yml
db_password: "{{ vault_db_password }}"
Why → The prefix pattern keeps names greppable while values stay encrypted.
Interview tip → Rotating is non-negotiable; Git history still holds the old value.
More on Security: Vault, Become and Compliance
You need separate vault passwords for staging and prod.IntermediateHow do you change the vault password for all encrypted files?IntermediateA CI pipeline needs the vault password without storing it in the repo.IntermediateYou want to see the value inside an encrypted file without writing a decrypted copy to disk.BeginnerOnly one value in a vars file is secret and you want it in the same file as plain values.BeginnerA task needs root on the target but your user has only limited sudo rights.Intermediate