Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions tests/tasks/clone_kernel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
state: present
- copy_default: "{{ __bootloader_copy_default }}"
default: "{{ __bootloader_make_default | d(false) }}"
include_role:
name: linux-system-roles.bootloader
include_tasks: tasks/run_role_with_clear_facts.yml

- name: Flush handlers
meta: flush_handlers
Expand All @@ -41,5 +40,4 @@
- name: Get bootloader_facts
vars:
bootloader_gather_facts: true
include_role:
name: linux-system-roles.bootloader
include_tasks: tasks/run_role_with_clear_facts.yml
37 changes: 37 additions & 0 deletions tests/tasks/run_role_with_clear_facts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
# Task file: clear_facts, run linux-system-roles.bootloader.
# Include this with include_tasks or import_tasks
# Input:
# - __sr_tasks_from: tasks_from to run - same as tasks_from in include_role
# - __sr_public: export private vars from role - same as public in include_role
# - __sr_failed_when: set to false to ignore role errors - same as failed_when in include_role
- name: Clear facts
meta: clear_facts

# note that you can use failed_when with import_role but not with include_role
# so this simulates the __sr_failed_when false case
# Q: Why do we need a separate task to run the role normally? Why not just
# run the role in the block and rethrow the error in the rescue block?
# A: Because you cannot rethrow the error in exactly the same way as the role does.
# It might be possible to exactly reconstruct ansible_failed_result but it's not worth the effort.
- name: Run the role with __sr_failed_when false
when:
- __sr_failed_when is defined
- not __sr_failed_when
block:
- name: Run the role
include_role:
name: linux-system-roles.bootloader
tasks_from: "{{ __sr_tasks_from | default('main') }}"
public: "{{ __sr_public | default(false) }}"
rescue:
- name: Ignore the failure when __sr_failed_when is false
debug:
msg: Ignoring failure when __sr_failed_when is false

- name: Run the role normally
include_role:
name: linux-system-roles.bootloader
tasks_from: "{{ __sr_tasks_from | default('main') }}"
public: "{{ __sr_public | default(false) }}"
when: __sr_failed_when | d(true)
13 changes: 4 additions & 9 deletions tests/tests_add_rm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
---
- name: Test creating, modifying, and removing kernels
hosts: all
gather_facts: false
tags:
- tests::reboot
vars:
Expand All @@ -16,8 +15,7 @@
- name: Get bootloader_facts
vars:
bootloader_gather_facts: true
include_role:
name: linux-system-roles.bootloader
include_tasks: tasks/run_role_with_clear_facts.yml

- name: Skip test on ostree systems
meta: end_host
Expand Down Expand Up @@ -92,8 +90,7 @@
- kernel:
path: "{{ __default_kernel.kernel }}_clone2"
default: true
include_role:
name: linux-system-roles.bootloader
include_tasks: tasks/run_role_with_clear_facts.yml

- name: Unreachable task
fail:
Expand All @@ -118,8 +115,7 @@
state: present
- copy_default: true
state: absent
include_role:
name: linux-system-roles.bootloader
include_tasks: tasks/run_role_with_clear_facts.yml

- name: Remove Clone2 kernel with kernel path
vars:
Expand All @@ -128,8 +124,7 @@
- kernel:
path: "{{ __default_kernel.kernel }}_clone2"
state: absent
include_role:
name: linux-system-roles.bootloader
include_tasks: tasks/run_role_with_clear_facts.yml

- name: Verify that kernel is removed {{ item }}
assert:
Expand Down
9 changes: 3 additions & 6 deletions tests/tests_bool_null_not_allowed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
- name: Validate no boolean true values for bootloader values
block:
- name: Try to pass boolean true for bootloader values
include_role:
name: linux-system-roles.bootloader
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
bootloader_settings:
- kernel: ALL
Expand Down Expand Up @@ -39,8 +38,7 @@
- name: Validate no boolean false values for bootloader values
block:
- name: Try to pass boolean false for bootloader values
include_role:
name: linux-system-roles.bootloader
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
bootloader_settings:
- kernel: ALL
Expand Down Expand Up @@ -69,8 +67,7 @@
- name: Validate no boolean null values for bootloader values
block:
- name: Try to pass boolean null for bootloader values
include_role:
name: linux-system-roles.bootloader
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
bootloader_settings:
- kernel: ALL
Expand Down
4 changes: 1 addition & 3 deletions tests/tests_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
---
- name: Ensure that the role runs with default parameters
hosts: all
gather_facts: false # for testing the role fact gathering
tasks:
- name: Skip on s390x architecture
include_tasks: tasks/skip_on_s390x.yml

- name: Run with default parameters
include_role:
name: linux-system-roles.bootloader
include_tasks: tasks/run_role_with_clear_facts.yml
1 change: 0 additions & 1 deletion tests/tests_include_vars_from_parent.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
- name: Test role include variable override
hosts: all
gather_facts: true
tasks:
- name: Skip on s390x architecture
include_tasks: tasks/skip_on_s390x.yml
Expand Down
10 changes: 3 additions & 7 deletions tests/tests_password.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
---
- name: Test bootloader_settings variable
hosts: all
gather_facts: false
tasks:
- name: Skip on s390x architecture
include_tasks: tasks/skip_on_s390x.yml
Expand All @@ -12,8 +11,7 @@
- name: Set boot loader password
vars:
bootloader_password: test-pass
include_role:
name: linux-system-roles.bootloader
include_tasks: tasks/run_role_with_clear_facts.yml

- name: Get contents of {{ __bootloader_user_conf }}
command: cat {{ __bootloader_user_conf }}
Expand All @@ -26,8 +24,7 @@
- name: Remove boot loader password
vars:
bootloader_remove_password: true
include_role:
name: linux-system-roles.bootloader
include_tasks: tasks/run_role_with_clear_facts.yml

- name: Get stat of {{ __bootloader_user_conf }}
stat:
Expand All @@ -41,5 +38,4 @@
- name: Remove boot loader password
vars:
bootloader_remove_password: true
include_role:
name: linux-system-roles.bootloader
include_tasks: tasks/run_role_with_clear_facts.yml
13 changes: 4 additions & 9 deletions tests/tests_settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
---
- name: Test bootloader_settings variable
hosts: all
gather_facts: false
tags:
- tests::reboot
vars:
Expand All @@ -16,8 +15,7 @@
- name: Get bootloader_facts
vars:
bootloader_gather_facts: true
include_role:
name: linux-system-roles.bootloader
include_tasks: tasks/run_role_with_clear_facts.yml

- name: Skip test on ostree systems
meta: end_host
Expand Down Expand Up @@ -83,8 +81,7 @@
path: "{{ __default_kernel.kernel }}"
default: true
bootloader_timeout: 6
include_role:
name: linux-system-roles.bootloader
include_tasks: tasks/run_role_with_clear_facts.yml

- name: Flush handlers
meta: flush_handlers
Expand Down Expand Up @@ -129,8 +126,7 @@
- name: option_with_value
state: absent
bootloader_timeout: 4
include_role:
name: linux-system-roles.bootloader
include_tasks: tasks/run_role_with_clear_facts.yml

- name: Flush handlers
meta: flush_handlers
Expand Down Expand Up @@ -168,8 +164,7 @@
value: tty0
state: present
bootloader_timeout: 4
include_role:
name: linux-system-roles.bootloader
include_tasks: tasks/run_role_with_clear_facts.yml

- name: Flush handlers
meta: flush_handlers
Expand Down
Loading