Skip to content

feat: Support extra dracut settings for static IP#268

Open
richm wants to merge 1 commit into
linux-system-roles:mainfrom
richm:feat-support-static-networking
Open

feat: Support extra dracut settings for static IP#268
richm wants to merge 1 commit into
linux-system-roles:mainfrom
richm:feat-support-static-networking

Conversation

@richm

@richm richm commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Feature: Introduce the nbde_client_extra_dracut_settings variable.
This is a list of strings written to
/etc/dracut.conf.d/nbde_client.conf in addition to the implicit
platform-specific __nbde_client_dracut_settings.

Reason: NBDE clients with static IP addressing need custom early-boot
network settings in dracut (for example kernel_cmdline with a static
ip= and nameserver). Previously the role only wrote fixed platform
settings, so users had to disable early boot or manage dracut config
outside the role.

Result: Users can pass extra dracut configuration lines via
nbde_client_extra_dracut_settings (documented in README.md) while
keeping the role's implicit settings. A new integration test verifies
the static IP kernel_cmdline example is written to the conf file.

Assisted-by: Cursor using models Cursor Grok 4.5, Composer 2.5, Sonnet 5

Signed-off-by: Rich Megginson rmeggins@redhat.com

Summary by CodeRabbit

  • New Features

    • Added support for configuring additional dracut settings for early-boot networking.
    • Extra settings can now be supplied as a list and are included in the generated dracut configuration.
  • Documentation

    • Updated role variable documentation with configuration guidance and an example for static IP scenarios.
  • Tests

    • Added coverage for setting persistence and idempotent repeated application.

Feature: Introduce the nbde_client_extra_dracut_settings variable.
This is a list of strings written to
/etc/dracut.conf.d/nbde_client.conf in addition to the implicit
platform-specific __nbde_client_dracut_settings.

Reason: NBDE clients with static IP addressing need custom early-boot
network settings in dracut (for example kernel_cmdline with a static
ip= and nameserver). Previously the role only wrote fixed platform
settings, so users had to disable early boot or manage dracut config
outside the role.

Result: Users can pass extra dracut configuration lines via
nbde_client_extra_dracut_settings (documented in README.md) while
keeping the role's implicit settings. A new integration test verifies
the static IP kernel_cmdline example is written to the conf file.

Assisted-by: Cursor using models Cursor Grok 4.5, Composer 2.5, Sonnet 5

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
@richm
richm requested review from sergio-correia and spetrosi July 20, 2026 14:31
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

The role adds nbde_client_extra_dracut_settings, renders it alongside platform-specific dracut settings, documents its usage, and tests default presence, output contents, and idempotency.

Extra dracut settings

Layer / File(s) Summary
Settings variable contract
defaults/main.yml, README.md
Defines the new variable with an empty-list default and documents its dracut configuration format and example usage.
Settings rendering and validation
templates/nbde_client.conf, tests/tests_default_vars.yml, tests/tests_extra_dracut_settings.yml
Renders platform-specific and extra settings together, then verifies the generated configuration and unchanged content on rerun.

Possibly related PRs

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed Conventional Commits format is used and the title accurately reflects the added dracut settings support.
Description check ✅ Passed Core sections for enhancement, reason, and result are present; only the issue tracker section is missing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Format ✅ Passed The PR description includes Feature, Reason, Result, Signed-off-by, and optional Assisted-by, matching the template requirements.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
defaults/main.yml

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

tests/tests_default_vars.yml

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

tests/tests_extra_dracut_settings.yml

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
tests/tests_extra_dracut_settings.yml (1)

1-1: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove AI-generation artifact.

Consider removing this auto-generated comment before merging, as it does not add value to the codebase.

♻️ Proposed fix
-# Generated by: Cursor using models Cursor Grok 4.5, Composer 2.5, Sonnet 5
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/tests_extra_dracut_settings.yml` at line 1, Remove the auto-generated
“Generated by” comment from tests/tests_extra_dracut_settings.yml, leaving the
file content otherwise unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/tests_extra_dracut_settings.yml`:
- Around line 11-13: Extend the test task block in
tests_extra_dracut_settings.yml with a failure scenario for
nbde_client_extra_dracut_settings, passing an invalid value such as a dictionary
instead of a list of strings and asserting that role execution fails. Preserve
the existing success and idempotency checks.
- Around line 8-18: Update tests/tests_extra_dracut_settings.yml at lines 8-18
and 49-53: use ansible.builtin.include_tasks for both wrapper invocations, and
move nbde_client_extra_dracut_settings from the play-level vars into each
invocation’s vars block. Do not alter the other tasks unless required for these
corrections.

---

Nitpick comments:
In `@tests/tests_extra_dracut_settings.yml`:
- Line 1: Remove the auto-generated “Generated by” comment from
tests/tests_extra_dracut_settings.yml, leaving the file content otherwise
unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 568d5884-403a-4e72-ab2c-a1cabc7d5491

📥 Commits

Reviewing files that changed from the base of the PR and between f7a8153 and 98183ce.

📒 Files selected for processing (5)
  • README.md
  • defaults/main.yml
  • templates/nbde_client.conf
  • tests/tests_default_vars.yml
  • tests/tests_extra_dracut_settings.yml

Comment on lines +8 to +18
nbde_client_extra_dracut_settings:
- "{{ __nbde_client_test_extra_dracut_line }}"

tasks:
- name: Run the test
block:
- name: Use nbde_client role
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__sr_public: true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Align role invocations with path instructions.
Both role invocations in this test define the input variables at the play level and omit the ansible.builtin. prefix, which violates the role invocation pattern required by the path instructions. The role configuration variables must be passed directly within the vars block of the centrally managed wrapper.

  • tests/tests_extra_dracut_settings.yml#L8-L18: Use ansible.builtin.include_tasks and move nbde_client_extra_dracut_settings from the play's vars into this task's vars block.
  • tests/tests_extra_dracut_settings.yml#L49-L53: Apply the same correction to the idempotency run, using the FQCN and including nbde_client_extra_dracut_settings in its vars block.

(Note: Consider adding the ansible.builtin. prefix to the other tasks in this file—such as slurp, set_fact, assert, and file—to fully align with modern Ansible best practices.)

📍 Affects 1 file
  • tests/tests_extra_dracut_settings.yml#L8-L18 (this comment)
  • tests/tests_extra_dracut_settings.yml#L49-L53
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/tests_extra_dracut_settings.yml` around lines 8 - 18, Update
tests/tests_extra_dracut_settings.yml at lines 8-18 and 49-53: use
ansible.builtin.include_tasks for both wrapper invocations, and move
nbde_client_extra_dracut_settings from the play-level vars into each
invocation’s vars block. Do not alter the other tasks unless required for these
corrections.

Source: Path instructions

Comment on lines +11 to +13
tasks:
- name: Run the test
block:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Verify failure scenarios in the test.

As per path instructions, "Tests should verify both success and failure scenarios". This test currently only validates the success path and idempotency. Please add an additional task block that expects a failure (for example, by intentionally providing an invalid type, such as a dictionary instead of a list of strings, to nbde_client_extra_dracut_settings and asserting that the role execution fails).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/tests_extra_dracut_settings.yml` around lines 11 - 13, Extend the test
task block in tests_extra_dracut_settings.yml with a failure scenario for
nbde_client_extra_dracut_settings, passing an invalid value such as a dictionary
instead of a list of strings and asserting that role execution fails. Preserve
the existing success and idempotency checks.

Source: Path instructions

@richm

richm commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

[citest]

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.

1 participant