Interview Prep/Ansible/Security: Vault, Become and Compliance

Only one value in a vars file is secret and you want it in the same file as plain values.

BeginnerScenarioSecurity: Vault, Become and Compliance
Answer

Situation read → Inline encryption.

What I'd do →

ansible-vault encrypt_string --vault-id prod@prompt 's3cr3t' --name 'db_password'

Paste the resulting !vault | block into the YAML.

Why → It keeps diffs readable for non-secret lines.

Interview tip → Whole-file encryption hides structure from reviewers; inline shows the keys. Choose by team preference.

All Ansible questions Roadmap: Ansible

More on Security: Vault, Become and Compliance