|
| 1 | +# Generated by: Cursor using models Cursor Grok 4.5, Composer 2.5, Sonnet 5 |
| 2 | +--- |
| 3 | +- name: Test nbde_client_extra_dracut_settings |
| 4 | + hosts: all |
| 5 | + vars: |
| 6 | + __nbde_client_test_extra_dracut_line: >- |
| 7 | + kernel_cmdline+=" ip=192.0.2.10::192.0.2.1:255.255.255.0::ens3:none nameserver=192.0.2.100 " |
| 8 | + nbde_client_extra_dracut_settings: |
| 9 | + - "{{ __nbde_client_test_extra_dracut_line }}" |
| 10 | + |
| 11 | + tasks: |
| 12 | + - name: Run the test |
| 13 | + block: |
| 14 | + - name: Use nbde_client role |
| 15 | + include_tasks: tasks/run_role_with_clear_facts.yml |
| 16 | + vars: |
| 17 | + __sr_public: true |
| 18 | + |
| 19 | + - name: Read generated dracut config |
| 20 | + slurp: |
| 21 | + src: /etc/dracut.conf.d/nbde_client.conf |
| 22 | + register: __nbde_client_dracut_conf |
| 23 | + |
| 24 | + - name: Decode dracut config content |
| 25 | + set_fact: |
| 26 | + __nbde_client_dracut_conf_content: "{{ |
| 27 | + __nbde_client_dracut_conf.content | b64decode }}" |
| 28 | + |
| 29 | + - name: Verify extra dracut setting is present |
| 30 | + assert: |
| 31 | + that: |
| 32 | + - __nbde_client_test_extra_dracut_line in |
| 33 | + __nbde_client_dracut_conf_content |
| 34 | + fail_msg: >- |
| 35 | + Expected /etc/dracut.conf.d/nbde_client.conf to contain |
| 36 | + {{ __nbde_client_test_extra_dracut_line }}. Content was: |
| 37 | + {{ __nbde_client_dracut_conf_content }} |
| 38 | +
|
| 39 | + - name: Verify implicit dracut settings are present |
| 40 | + assert: |
| 41 | + that: |
| 42 | + - item in __nbde_client_dracut_conf_content |
| 43 | + fail_msg: >- |
| 44 | + Expected /etc/dracut.conf.d/nbde_client.conf to contain |
| 45 | + implicit setting {{ item }}. Content was: |
| 46 | + {{ __nbde_client_dracut_conf_content }} |
| 47 | + loop: "{{ __nbde_client_dracut_settings }}" |
| 48 | + |
| 49 | + - name: Use nbde_client role again for idempotency |
| 50 | + include_tasks: tasks/run_role_with_clear_facts.yml |
| 51 | + vars: |
| 52 | + __sr_public: true |
| 53 | + |
| 54 | + - name: Re-read generated dracut config |
| 55 | + slurp: |
| 56 | + src: /etc/dracut.conf.d/nbde_client.conf |
| 57 | + register: __nbde_client_dracut_conf_again |
| 58 | + |
| 59 | + - name: Verify dracut config is unchanged after second run |
| 60 | + assert: |
| 61 | + that: |
| 62 | + - __nbde_client_dracut_conf.content == |
| 63 | + __nbde_client_dracut_conf_again.content |
| 64 | + fail_msg: Dracut config changed on second role run |
| 65 | + |
| 66 | + - name: Run the role with early boot disabled |
| 67 | + vars: |
| 68 | + nbde_client_early_boot: false |
| 69 | + nbde_client_extra_dracut_settings: |
| 70 | + - >- |
| 71 | + kernel_cmdline+=" ip=192.0.2.10::192.0.2.1:255.255.255.0::ens3:none |
| 72 | + nameserver=192.0.2.100 " |
| 73 | + block: |
| 74 | + - name: Use nbde_client role with conflicting settings |
| 75 | + include_tasks: tasks/run_role_with_clear_facts.yml |
| 76 | + |
| 77 | + - name: Fail if the role did not reject conflicting settings |
| 78 | + fail: |
| 79 | + msg: >- |
| 80 | + Role should fail when nbde_client_early_boot is false and |
| 81 | + nbde_client_extra_dracut_settings is set |
| 82 | +
|
| 83 | + rescue: |
| 84 | + - name: Assert the early boot conflict error message |
| 85 | + assert: |
| 86 | + that: |
| 87 | + - >- |
| 88 | + 'nbde_client_extra_dracut_settings requires |
| 89 | + nbde_client_early_boot' in ansible_failed_result.msg |
| 90 | + fail_msg: >- |
| 91 | + Unexpected failure: |
| 92 | + {{ ansible_failed_result.msg | default(ansible_failed_result) }} |
| 93 | +
|
| 94 | + always: |
| 95 | + - name: Clean up generated dracut config |
| 96 | + file: |
| 97 | + path: /etc/dracut.conf.d/nbde_client.conf |
| 98 | + state: absent |
| 99 | + tags: |
| 100 | + - tests::cleanup |
| 101 | + |
| 102 | + - name: Run the role with no settings to clean up |
| 103 | + include_tasks: tasks/run_role_with_clear_facts.yml |
| 104 | + vars: |
| 105 | + nbde_client_extra_dracut_settings: [] |
| 106 | + nbde_client_early_boot: true |
| 107 | + nbde_client_bindings: [] |
| 108 | + tags: |
| 109 | + - tests::cleanup |
| 110 | + |
| 111 | +# vim:set ts=2 sw=2 et: |
0 commit comments