fix: add verbosity-based no_log to facts modules#276
Merged
richm merged 1 commit intolinux-system-roles:mainfrom May 7, 2026
Merged
fix: add verbosity-based no_log to facts modules#276richm merged 1 commit intolinux-system-roles:mainfrom
richm merged 1 commit intolinux-system-roles:mainfrom
Conversation
- Add no_log: "{{ ansible_verbosity < 2 }}" to package_facts
This hides verbose facts output unless ansible_verbosity >= 2,
reducing log clutter during normal operation while allowing
full output when debugging with -vv or higher.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds verbosity-aware no_log behavior to the package_facts task to reduce log noise while preserving debuggability. Sequence diagram for verbosity-based no_log behavior in package_facts tasksequenceDiagram
actor AnsibleUser
participant AnsibleCLI
participant Playbook
participant Task_package_facts
participant Logger
AnsibleUser->>AnsibleCLI: run ansible_playbook with verbosity
AnsibleCLI->>Playbook: execute tasks
Playbook->>Task_package_facts: run package_facts
Task_package_facts->>Task_package_facts: evaluate ansible_verbosity < 2
alt verbosity_less_than_2
Task_package_facts->>Logger: suppress facts output (no_log true)
else verbosity_2_or_more
Task_package_facts->>Logger: log full package_facts output (no_log false)
end
Logger-->>AnsibleCLI: aggregated logs
AnsibleCLI-->>AnsibleUser: display logs according to verbosity
Flow diagram for no_log decision in package_facts taskflowchart TD
Start[Start package_facts task]
V[Read ansible_verbosity]
C{ansible_verbosity < 2}
NLTrue[Set no_log to true
hide package_facts output]
NLFalse[Set no_log to false
show package_facts output]
End[Continue playbook execution]
Start --> V --> C
C -->|yes| NLTrue --> End
C -->|no| NLFalse --> End
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The
no_logkey should be indented at the task level (alongsidename,package_facts, andwhen) rather than underpackage_facts, sinceno_logis a task attribute, not a module parameter; otherwise Ansible will treat it as an unexpected argument topackage_facts. - To make the verbosity check more robust, consider explicitly casting
ansible_verbosityto an integer (no_log: "{{ (ansible_verbosity | int) < 2 }}") so the condition behaves predictably even ifansible_verbosityis passed as a string.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `no_log` key should be indented at the task level (alongside `name`, `package_facts`, and `when`) rather than under `package_facts`, since `no_log` is a task attribute, not a module parameter; otherwise Ansible will treat it as an unexpected argument to `package_facts`.
- To make the verbosity check more robust, consider explicitly casting `ansible_verbosity` to an integer (`no_log: "{{ (ansible_verbosity | int) < 2 }}"`) so the condition behaves predictably even if `ansible_verbosity` is passed as a string.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
richm
approved these changes
May 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feature: Add verbosity-based no_log to facts modules.
Reason: Facts modules like package_facts produce verbose output that clutters logs during normal operation, making it difficult to review playbook execution.
Result:
🤖 Generated with Claude Code
Summary by Sourcery
New Features: