How do you stop secrets from leaking into logs and output?
BeginnerProductionSecurity and Secrets
Answer
no_log: trueon tasks that handle secrets (and on loops, to hide item values).diff: falsefor templates containing passwords, because--diffprints content.- Avoid
-vvvin shared CI logs: connection debug output can include arguments. - Never
debuga secret variable. - Keep secrets out of command lines: use
content:or files rather thanshell: mysql -p{{ pw }}, which shows inps. - 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.
More on Security and Secrets
How do you set up a secure automation user and SSH access?BeginnerHow do you give the automation user sudo with least privilege?IntermediateWhat are the alternatives to Ansible Vault for secrets, and when do you use them?IntermediateHow do you read AWS Secrets Manager and SSM parameters in a playbook?IntermediateHow do you integrate HashiCorp Vault with Ansible?AdvancedHow do you handle the vault password in CI/CD?Intermediate