-
Notifications
You must be signed in to change notification settings - Fork 23
feat: Support extra dracut settings for static IP #268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
richm
wants to merge
1
commit into
linux-system-roles:main
Choose a base branch
from
richm:feat-support-static-networking
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| # nbde_client dracut config | ||
| {{ ansible_managed | comment }} | ||
| {{ "system_role:nbde_client" | comment(prefix="", postfix="") }} | ||
| {% for line in __nbde_client_dracut_settings %} | ||
| {% for line in __nbde_client_dracut_settings + nbde_client_extra_dracut_settings %} | ||
| {{ line }} | ||
| {% endfor %} |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| # Generated by: Cursor using models Cursor Grok 4.5, Composer 2.5, Sonnet 5 | ||
| --- | ||
| - name: Test nbde_client_extra_dracut_settings | ||
| hosts: all | ||
| vars: | ||
| __nbde_client_test_extra_dracut_line: >- | ||
| kernel_cmdline+=" ip=192.0.2.10::192.0.2.1:255.255.255.0::ens3:none nameserver=192.0.2.100 " | ||
| nbde_client_extra_dracut_settings: | ||
| - "{{ __nbde_client_test_extra_dracut_line }}" | ||
|
|
||
| tasks: | ||
| - name: Run the test | ||
| block: | ||
|
richm marked this conversation as resolved.
|
||
| - name: Use nbde_client role | ||
| include_tasks: tasks/run_role_with_clear_facts.yml | ||
| vars: | ||
| __sr_public: true | ||
|
|
||
|
richm marked this conversation as resolved.
|
||
| - name: Read generated dracut config | ||
| slurp: | ||
| src: /etc/dracut.conf.d/nbde_client.conf | ||
| register: __nbde_client_dracut_conf | ||
|
|
||
| - name: Decode dracut config content | ||
| set_fact: | ||
| __nbde_client_dracut_conf_content: "{{ | ||
| __nbde_client_dracut_conf.content | b64decode }}" | ||
|
|
||
| - name: Verify extra dracut setting is present | ||
| assert: | ||
| that: | ||
| - __nbde_client_test_extra_dracut_line in | ||
| __nbde_client_dracut_conf_content | ||
| fail_msg: >- | ||
| Expected /etc/dracut.conf.d/nbde_client.conf to contain | ||
| {{ __nbde_client_test_extra_dracut_line }}. Content was: | ||
| {{ __nbde_client_dracut_conf_content }} | ||
|
|
||
| - name: Verify implicit dracut settings are present | ||
| assert: | ||
| that: | ||
| - item in __nbde_client_dracut_conf_content | ||
| fail_msg: >- | ||
| Expected /etc/dracut.conf.d/nbde_client.conf to contain | ||
| implicit setting {{ item }}. Content was: | ||
| {{ __nbde_client_dracut_conf_content }} | ||
| loop: "{{ __nbde_client_dracut_settings }}" | ||
|
|
||
| - name: Use nbde_client role again for idempotency | ||
| include_tasks: tasks/run_role_with_clear_facts.yml | ||
| vars: | ||
| __sr_public: true | ||
|
|
||
| - name: Re-read generated dracut config | ||
| slurp: | ||
| src: /etc/dracut.conf.d/nbde_client.conf | ||
| register: __nbde_client_dracut_conf_again | ||
|
|
||
| - name: Verify dracut config is unchanged after second run | ||
| assert: | ||
| that: | ||
| - __nbde_client_dracut_conf.content == | ||
| __nbde_client_dracut_conf_again.content | ||
| fail_msg: Dracut config changed on second role run | ||
|
|
||
| - name: Run the role with early boot disabled | ||
| vars: | ||
| nbde_client_early_boot: false | ||
| nbde_client_extra_dracut_settings: | ||
| - >- | ||
| kernel_cmdline+=" ip=192.0.2.10::192.0.2.1:255.255.255.0::ens3:none | ||
| nameserver=192.0.2.100 " | ||
| block: | ||
| - name: Use nbde_client role with conflicting settings | ||
| include_tasks: tasks/run_role_with_clear_facts.yml | ||
|
|
||
| - name: Fail if the role did not reject conflicting settings | ||
| fail: | ||
| msg: >- | ||
| Role should fail when nbde_client_early_boot is false and | ||
| nbde_client_extra_dracut_settings is set | ||
|
|
||
| rescue: | ||
| - name: Assert the early boot conflict error message | ||
| assert: | ||
| that: | ||
| - >- | ||
| 'nbde_client_extra_dracut_settings requires | ||
| nbde_client_early_boot' in ansible_failed_result.msg | ||
| fail_msg: >- | ||
| Unexpected failure: | ||
| {{ ansible_failed_result.msg | default(ansible_failed_result) }} | ||
|
|
||
| always: | ||
| - name: Clean up generated dracut config | ||
| file: | ||
| path: /etc/dracut.conf.d/nbde_client.conf | ||
| state: absent | ||
| tags: | ||
| - tests::cleanup | ||
|
richm marked this conversation as resolved.
|
||
|
|
||
| - name: Run the role with no settings to clean up | ||
| include_tasks: tasks/run_role_with_clear_facts.yml | ||
| vars: | ||
| nbde_client_extra_dracut_settings: [] | ||
| nbde_client_early_boot: true | ||
| nbde_client_bindings: [] | ||
| tags: | ||
| - tests::cleanup | ||
|
|
||
| # vim:set ts=2 sw=2 et: | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.