fix: add verbosity-based no_log to facts modules#219
Merged
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 facts collection task so package facts output is suppressed in normal runs but visible when running with higher Ansible verbosity. Sequence diagram for verbosity-based no_log behavior in package_facts tasksequenceDiagram
actor User
participant AnsibleCLI
participant Playbook
participant Task_package_facts
participant Module_package_facts
participant Logger
User->>AnsibleCLI: run ansible_playbook (optional -v / -vv)
AnsibleCLI->>Playbook: load tasks
Playbook->>Task_package_facts: execute task Get_the_rpm_package_facts
Task_package_facts->>Task_package_facts: compute no_log = ansible_verbosity < 2
alt no_log is true (ansible_verbosity < 2)
Task_package_facts->>Module_package_facts: invoke module with no_log true
Module_package_facts->>Logger: send facts output (hidden in logs)
Logger-->>Playbook: log task status only
else no_log is false (ansible_verbosity >= 2)
Task_package_facts->>Module_package_facts: invoke module with no_log false
Module_package_facts->>Logger: send full facts output
Logger-->>Playbook: log task status and facts content
end
Playbook-->>AnsibleCLI: aggregate results
AnsibleCLI-->>User: display output according to verbosity
Flow diagram for determining no_log value from ansible_verbosityflowchart TD
A[Start task Get the rpm package facts] --> B[Read ansible_verbosity]
B --> C{Is ansible_verbosity < 2?}
C -->|Yes| D[Set no_log to true]
C -->|No| E[Set no_log to false]
D --> F[Run package_facts module with output hidden in logs]
E --> G[Run package_facts module with full output shown in logs]
F --> H[Continue playbook execution]
G --> H[Continue playbook execution]
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 new
no_logline appears at the same indentation level aspackage_facts:; if this is meant to be a task-level attribute it should align withname/package_facts, and if it’s a module argument it should be indented underpackage_facts:to avoid breaking the task YAML structure. - Consider explicitly casting
ansible_verbosityto an integer (e.g.{{ (ansible_verbosity | int) < 2 }}) so the no_log condition remains robust even if the verbosity value is provided as a string in some environments.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `no_log` line appears at the same indentation level as `package_facts:`; if this is meant to be a task-level attribute it should align with `name`/`package_facts`, and if it’s a module argument it should be indented under `package_facts:` to avoid breaking the task YAML structure.
- Consider explicitly casting `ansible_verbosity` to an integer (e.g. `{{ (ansible_verbosity | int) < 2 }}`) so the no_log condition remains robust even if the verbosity value is provided as a string in some environments.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
Enhancements: