1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
# no-log-password
This rule ensures playbooks do not write passwords to logs when using loops.
Always set the `no_log: true` attribute to protect sensitive data.
While most Ansible modules mask sensitive data, using secrets inside a loop can result in those secrets being logged.
Explicitly adding `no_log: true` prevents accidentally exposing secrets.
## Problematic Code
```yaml
---
- name: Example playbook
hosts: localhost
tasks:
- name: Log user passwords
ansible.builtin.user:
name: john_doe
comment: John Doe
uid: 1040
group: admin
password: "{{ item }}"
with_items:
- wow
no_log: false # <- Sets the no_log attribute to false.
```
## Correct Code
```yaml
---
- name: Example playbook
hosts: localhost
tasks:
- name: Do not log user passwords
ansible.builtin.user:
name: john_doe
comment: John Doe
uid: 1040
group: admin
password: "{{ item }}"
with_items:
- wow
no_log: true # <- Sets the no_log attribute to a non-false value.
```
!!! note
This rule can be automatically fixed using [`--fix`](../autofix.md) option.
|