CI logs show database passwords in plain text after adding `--diff`
AdvancedTroubleshootingModules, Idempotency and Handlers
Answer
Likely causes → --diff prints the before and after content of templated files, including secrets that were rendered from Vault. no_log hides the task result, but teams often forget it on templates.
Fix → Rotate the leaked credentials. Then turn off the diff for sensitive files:
- ansible.builtin.template:
src: db.conf.j2
dest: /etc/app/db.conf
mode: "0600"
diff: false
no_log: true
Scrub or expire the CI job logs.
Prevent → Keep secrets in separate files rendered with diff: false, or load them at runtime from a secret manager. Audit for tasks that render vaulted variables without no_log.
More on Modules, Idempotency and Handlers
`ERROR! The requested handler 'Restart nginx' was not found in either the main handlers list nor in the listening handlers list`BeginnerA handler named `restart {{ app_service }}` is never found when notified as `restart myapp`AdvancedA `command` task reports `changed` on every run, and the Molecule idempotence check failsBeginner`curl ... | tar xz` fails on the host but the `shell` task reports successIntermediate`lineinfile` appends the same line again on every runIntermediate`lineinfile` with `backrefs: true` reports `ok` but the line was never addedIntermediate