Skip to content

feat: new variable nbde_client_secure_logging defaulting to true#257

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

feat: new variable nbde_client_secure_logging defaulting to true#257
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: Introduce the nbde_client_secure_logging variable that defaults to true and using verbosity-based logging for facts modules.

Reason: Currently, all sensitive tasks use hard-coded no_log: true, which makes debugging difficult. Users cannot see credential-related output even when troubleshooting authentication or secret management issues. Additionally, service_facts produces verbose output that clutters logs during normal operation.

Result:

  • Tasks handling credentials, secrets, and sensitive data now use no_log: "{{ nbde_client_secure_logging }}", allowing users to set nbde_client_secure_logging: false for debugging while maintaining secure defaults (true)
  • service_facts now uses no_log: "{{ ansible_verbosity < 2 }}", hiding verbose output unless -vv or higher verbosity is specified
  • New variable nbde_client_secure_logging documented in README.md with guidance on when to disable it
  • Users can now debug credential and secret issues without modifying role code

🤖 Generated with Claude Code

Summary by Sourcery

Introduce configurable secure logging for NBDE client tasks and adjust service facts logging based on Ansible verbosity.

New Features:

  • Add nbde_client_secure_logging variable to control suppression of sensitive task output, defaulting to secure behavior.

Enhancements:

  • Switch sensitive clevis-related tasks from hard-coded no_log to using the nbde_client_secure_logging setting.
  • Make service_facts logging conditional on Ansible verbosity to reduce noisy output at normal log levels.

Documentation:

  • Document the nbde_client_secure_logging variable and its recommended usage in the README.

- Replace literal no_log: true with nbde_client_secure_logging variable
- Add no_log: "{{ ansible_verbosity < 2 }}" to service_facts
- Add nbde_client_secure_logging: true to defaults/main.yml
- Document nbde_client_secure_logging variable in README.md

This change allows users to control logging of potentially sensitive
information by setting nbde_client_secure_logging: false for debugging,
while maintaining secure defaults.

For 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>
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 7, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds a configurable secure-logging toggle and verbosity-based logging behavior so that sensitive nbde_client tasks can be debugged when needed while keeping safe defaults, and documents the new variable.

Class diagram for nbde_client secure logging configuration and tasks

classDiagram
  class NbdeClientRole {
    bool nbde_client_early_boot
    list nbde_client_bindings
    bool nbde_client_secure_logging
  }

  class ServiceFactsTask {
    bool no_log
    +run(ansible_verbosity)
  }

  class ClevisCheckTask {
    bool no_log
    +run(bindings, nbde_client_secure_logging)
  }

  class ClevisPrepareKeyFilesTask {
    bool no_log
    +run(bindings, nbde_client_secure_logging)
  }

  class ClevisOperationsTask {
    bool no_log
    +run(bindings, data_dir, nbde_client_secure_logging)
  }

  NbdeClientRole --> ServiceFactsTask : configures
  NbdeClientRole --> ClevisCheckTask : configures
  NbdeClientRole --> ClevisPrepareKeyFilesTask : configures
  NbdeClientRole --> ClevisOperationsTask : configures

  ServiceFactsTask : no_log = ansible_verbosity < 2
  ClevisCheckTask : no_log = nbde_client_secure_logging
  ClevisPrepareKeyFilesTask : no_log = nbde_client_secure_logging
  ClevisOperationsTask : no_log = nbde_client_secure_logging
Loading

Flow diagram for secure logging and verbosity-based no_log behavior

flowchart TD
  Start(["Run nbde_client role"]) --> CheckSecureLogging

  CheckSecureLogging["Read nbde_client_secure_logging (default true)"] -->|true| SecureLoggingOn
  CheckSecureLogging -->|false| SecureLoggingOff

  SecureLoggingOn["Secure logging enabled"] --> SensitiveTasksNoLog
  SecureLoggingOff["Secure logging disabled for debugging"] --> SensitiveTasksLog

  SensitiveTasksNoLog["Sensitive tasks use no_log: nbde_client_secure_logging (true)"] --> EndSensitive
  SensitiveTasksLog["Sensitive tasks use no_log: nbde_client_secure_logging (false)"] --> EndSensitive

  subgraph ServiceFactsNoLogControl["service_facts logging control"]
    A["Invoke service_facts"] --> CheckVerbosity
    CheckVerbosity["Evaluate ansible_verbosity < 2"] -->|true| HideServiceFacts
    CheckVerbosity -->|false| ShowServiceFacts
    HideServiceFacts["no_log: ansible_verbosity < 2 (true) hides verbose output"]
    ShowServiceFacts["no_log: ansible_verbosity < 2 (false) shows detailed facts"]
  end

  Start --> ServiceFactsNoLogControl --> CheckSecureLogging
  EndSensitive(["Role completes with configured logging behavior"])
Loading

File-Level Changes

Change Details Files
Make service_facts output conditional on Ansible verbosity to reduce log noise in normal runs while still allowing verbose debugging.
  • Add no_log condition that hides service_facts output when ansible_verbosity is less than 2
  • Keep service_facts task behavior otherwise unchanged
tasks/main-clevis.yml
Replace hard-coded no_log: true on clevis credential- and secret-handling tasks with a new nbde_client_secure_logging variable so logging can be selectively disabled for debugging.
  • Update clevis check state task to use no_log templated on nbde_client_secure_logging
  • Update looped key-file preparation task to use no_log templated on nbde_client_secure_logging
  • Update clevis operations task to use no_log templated on nbde_client_secure_logging
tasks/main-clevis.yml
Introduce and document the nbde_client_secure_logging variable with a secure default.
  • Add nbde_client_secure_logging: true to role defaults to keep sensitive logging suppressed by default
  • Document nbde_client_secure_logging in README with guidance on when it is safe/appropriate to set it to false
defaults/main.yml
README.md

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.

@richm richm merged commit a4fd810 into linux-system-roles:main May 7, 2026
38 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