Skip to content

fix: add verbosity-based no_log to facts modules#619

Merged
richm merged 1 commit into
linux-system-roles:mainfrom
spetrosi:parametrize-no-log
May 7, 2026
Merged

fix: add verbosity-based no_log to facts modules#619
richm merged 1 commit into
linux-system-roles:mainfrom
spetrosi:parametrize-no-log

Conversation

@spetrosi
Copy link
Copy Markdown
Contributor

@spetrosi spetrosi commented May 7, 2026

Feature: Add verbosity-based no_log to facts modules.

Reason: Facts modules like service_facts produce verbose output that clutters logs during normal operation, making it difficult to review playbook execution.

Result:

  • service_facts now uses no_log: "{{ ansible_verbosity < 2 }}", hiding verbose output unless -vv or higher verbosity is specified
  • Users can still see full facts output when debugging by running with increased verbosity
  • No impact on normal operation, just cleaner logs

🤖 Generated with Claude Code

Summary by Sourcery

Enhancements:

  • Hide service_facts output from logs by default and only show it when Ansible verbosity is set to -vv or higher.

- Add no_log: "{{ ansible_verbosity < 2 }}" to 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>
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 7, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds verbosity-based no_log handling to the service_facts task in the blivet role to reduce log noise at normal verbosity while still allowing detailed facts output at higher verbosity levels.

Sequence diagram for verbosity-based no_log handling in service_facts task

sequenceDiagram
    actor AnsibleUser
    participant AnsibleController
    participant BlivetRole
    participant AnsibleFacts

    AnsibleUser->>AnsibleController: Run playbook with verbosity flag
    AnsibleController->>BlivetRole: Execute tasks in main_blivet

    BlivetRole->>AnsibleFacts: Check existing ansible_facts
    AnsibleFacts-->>BlivetRole: services and cryptsetup_services presence

    BlivetRole->>BlivetRole: Evaluate conditions
    Note over BlivetRole: when not services in ansible_facts
    Note over BlivetRole: and not cryptsetup_services in storage_skip_checks

    BlivetRole->>BlivetRole: Evaluate ansible_verbosity < 2
    alt ansible_verbosity < 2
        BlivetRole->>AnsibleFacts: Call service_facts with no_log true
        AnsibleFacts-->>BlivetRole: Gather service facts (hidden in logs)
    else ansible_verbosity >= 2
        BlivetRole->>AnsibleFacts: Call service_facts with no_log false
        AnsibleFacts-->>BlivetRole: Gather service facts (visible in logs)
    end

    BlivetRole-->>AnsibleController: Updated ansible_facts
    AnsibleController-->>AnsibleUser: Play recap with logs based on verbosity
Loading

Flow diagram for ansible_verbosity-based logging in service_facts task

flowchart TD
    A[Start blivet role tasks] --> B[Check if services in ansible_facts]
    B -->|yes| C[Skip Get service facts task]
    B -->|no| D[Check if cryptsetup_services in storage_skip_checks]
    D -->|yes| C
    D -->|no| E[Evaluate ansible_verbosity < 2]
    E -->|true| F[Run service_facts
no_log set to true]
    E -->|false| G[Run service_facts
no_log set to false]
    F --> H[Update ansible_facts]
    G --> H
    C --> I[Continue remaining tasks]
    H --> I
    I --> J[End blivet role tasks]
Loading

File-Level Changes

Change Details Files
Gate service_facts output behind verbosity-aware no_log to keep default logs clean while preserving debuggability.
  • Add no_log expression that evaluates to true when Ansible verbosity is lower than 2
  • Apply the no_log condition to the existing service_facts task in the blivet role
  • Ensure facts are still gathered unconditionally when the task runs; only log display is affected
tasks/main-blivet.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 10.16%. Comparing base (59fd1c6) to head (ec4865d).
⚠️ Report is 139 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (59fd1c6) and HEAD (ec4865d). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (59fd1c6) HEAD (ec4865d)
sanity 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #619      +/-   ##
==========================================
- Coverage   16.54%   10.16%   -6.39%     
==========================================
  Files           2        9       +7     
  Lines         284     2056    +1772     
  Branches       79        0      -79     
==========================================
+ Hits           47      209     +162     
- Misses        237     1847    +1610     
Flag Coverage Δ
sanity ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@richm richm merged commit 11741a1 into linux-system-roles:main May 7, 2026
35 of 40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants