Interview Prep/Ansible/Security and Secrets

How do you stop secrets from leaking into logs and output?

BeginnerProductionSecurity and Secrets
Answer
  • no_log: true on tasks that handle secrets (and on loops, to hide item values).
  • diff: false for templates containing passwords, because --diff prints content.
  • Avoid -vvv in shared CI logs: connection debug output can include arguments.
  • Never debug a secret variable.
  • Keep secrets out of command lines: use content: or files rather than shell: mysql -p{{ pw }}, which shows in ps.
  • Mask values in the CI system and restrict AWX job output access.

Test it: run once with no_log and grep the job log for a known secret fragment.

All Ansible questions Roadmap: Ansible

More on Security and Secrets