Skip to content

Commit 074ba4e

Browse files
spetrosiclaude
andcommitted
feat: Parametrize no_log usage in network role
- Replace literal no_log: true with network_secure_logging variable - Add no_log: "{{ ansible_verbosity < 2 }}" to package_facts and service_facts - Add network_secure_logging: true to defaults/main.yml - Document network_secure_logging variable in README.md This change allows users to control logging of potentially sensitive information by setting network_secure_logging: false for debugging, while maintaining secure defaults. For package_facts and service_facts, the role now uses verbosity-based logging to hide verbose output unless ansible_verbosity >= 2. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 1f5c1a4 commit 074ba4e

4 files changed

Lines changed: 10 additions & 5 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ the name prefix. List of variables:
115115
- `network_state` - The network state settings can be configured in the managed
116116
host, and the format and the syntax of the configuration should be consistent
117117
with the [nmstate state examples](https://nmstate.io/examples.html) (YAML).
118+
- `network_secure_logging` - If true, suppress potentially sensitive output from
119+
tasks that handle credentials, secrets, and other sensitive data. Set to false
120+
for debugging issues with credential handling or secret management, but be aware
121+
this may expose sensitive information in logs. Defaults to `true`.
118122

119123
## Examples of Variables
120124

defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,4 @@ __network_required_facts:
162162
# the 'gather_subset' parameter of the 'setup' module
163163
__network_required_facts_subsets: "{{ ['!all', '!min'] +
164164
__network_required_facts }}"
165+
network_secure_logging: true

tasks/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
enabled: true
158158
when:
159159
- network_provider == "nm" or network_state != {}
160-
no_log: true
160+
no_log: "{{ network_secure_logging }}"
161161

162162
# If any 802.1x connections are used, the wpa_supplicant
163163
# service is required to be running
@@ -176,7 +176,7 @@
176176
enabled: true
177177
when:
178178
- network_provider == "initscripts"
179-
no_log: true
179+
no_log: "{{ network_secure_logging }}"
180180

181181
- name: Ensure initscripts network file dependency is present
182182
copy:

tasks/set_facts.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
gather_subset: "{{ __network_required_facts_subsets }}"
66
when: __network_required_facts |
77
difference(ansible_facts.keys() | list) | length > 0
8-
no_log: true
8+
no_log: "{{ network_secure_logging }}"
99

1010
- name: Record role begin fingerprint
1111
sr_fingerprint:
@@ -27,9 +27,9 @@
2727

2828
- name: Check which services are running
2929
service_facts:
30-
no_log: true
30+
no_log: "{{ ansible_verbosity < 2 }}"
3131

3232
# needed for ansible_facts.packages
3333
- name: Check which packages are installed
3434
package_facts:
35-
no_log: true
35+
no_log: "{{ ansible_verbosity < 2 }}"

0 commit comments

Comments
 (0)