Interview Prep/Ansible/Modules, Idempotency and Handlers

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.

All Ansible questions Roadmap: Ansible

More on Modules, Idempotency and Handlers