fix: add verbosity-based no_log to facts modules#348
Merged
Conversation
- Add no_log: "{{ ansible_verbosity < 2 }}" to package_facts and service_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-dependent no_log behavior to Ansible facts tasks to reduce log noise while preserving debuggability. Flow diagram for ansible_verbosity-driven no_log in facts modulesflowchart TD
A[Start Ansible playbook] --> B[Run service_facts task]
B --> C{ansible_verbosity < 2}
C -- yes --> D[Set no_log to true for service_facts]
C -- no --> E[Set no_log to false for service_facts]
D --> F[Hide service_facts output in logs]
E --> G[Show service_facts output in logs]
F --> H[Run package_facts task]
G --> H[Run package_facts task]
H --> I{ansible_verbosity < 2}
I -- yes --> J[Set no_log to true for package_facts]
I -- no --> K[Set no_log to false for package_facts]
J --> L[Hide package_facts output in logs]
K --> M[Show package_facts output in logs]
L --> N[Continue remaining tasks]
M --> N[Continue remaining tasks]
N[End playbook]
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:
- To make this more robust across different execution contexts, consider guarding
ansible_verbositywith a default and explicit cast, e.g.no_log: "{{ (ansible_verbosity | default(0) | int) < 2 }}", so the task doesn’t break ifansible_verbosityis undefined or comes through as a string.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- To make this more robust across different execution contexts, consider guarding `ansible_verbosity` with a default and explicit cast, e.g. `no_log: "{{ (ansible_verbosity | default(0) | int) < 2 }}"`, so the task doesn’t break if `ansible_verbosity` is undefined or comes through 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 and service_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
Control verbosity of facts gathering tasks to reduce log noise in normal runs while preserving debug visibility.
New Features: