Sensitive data exposure in Ansible default logging settings

Apply no_log to sensitive task output, and protect debugging output and log stores separately.

Description

Ansible can display task inputs and results in its execution output. Whether a password, token or key appears depends on the task settings and the values it outputs.

Potential impact

Anyone with access to shared or archived logs may be able to read credentials recorded there.

Remediation

Set no_log: true on tasks that handle secrets. To suppress task details by default, set no_log=True under [defaults]. This also reduces the output available for troubleshooting.

Keep secrets out of separate debugging output and application logs. Check access and retention for CI logs and log stores, and rotate exposed credentials.

Examples

Check that your Ansible version supports the other options in these ansible.cfg excerpts.

Before

text
[defaults]
action_warnings=True
allow_unsafe_lookups=False
ask_pass=False
ask_vault_pass=False
debug=False
forks=5
gathering=implicit

After

text
[defaults]
action_warnings=True
allow_unsafe_lookups=False
ask_pass=False
ask_vault_pass=False
debug=False
forks=5
gathering=implicit
no_log=True

The second configuration suppresses task details by default. The setting leaves existing logs untouched.

References