Skip to content
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

fix: Fail on the s390x architecture with a not supported msg #96

Merged
merged 2 commits into from
Apr 16, 2024
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
7 changes: 7 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
- name: Set platform/version specific variables
include_tasks: tasks/set_vars.yml

- name: Fail on s390x architecture
fail:
msg: >-
This role does not support s390x architecture.
Let us know if you need the role to support it.
when: ansible_architecture == 's390x'

- name: Ensure required packages are installed
package:
name: "{{ __bootloader_packages }}"
Expand Down
20 changes: 20 additions & 0 deletions tests/tasks/assert_fail_on_s390x.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# SPDX-License-Identifier: MIT
---
- name: Assert failure on the s390x architecture
when: ansible_architecture == 's390x'
spetrosi marked this conversation as resolved.
Show resolved Hide resolved
block:
- name: Assert failure
assert:
that: __str in ansible_failed_result.msg
vars:
__str: This role does not support s390x architecture.

- name: End execution on s390x host to avoid failures in clean up
meta: end_host

# When this task file is included in a rescue block, and the above task is
# skipped, Ansible would report success considering that a failure was rescued
- name: Fail if in a rescue block
when: ansible_failed_result is defined
fail:
spetrosi marked this conversation as resolved.
Show resolved Hide resolved
msg: "{{ ansible_failed_result }}"
3 changes: 3 additions & 0 deletions tests/tests_add_rm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@
that: bootloader_facts | selectattr('title', 'defined') |
selectattr('title', 'search', 'Clone2') |
list | length == 0
rescue:
- name: Assert failure on s390x architecture
include_tasks: tasks/assert_fail_on_s390x.yml
always:
- name: Remove cloned kernels
command: >-
Expand Down
11 changes: 9 additions & 2 deletions tests/tests_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,12 @@
- name: Ensure that the role runs with default parameters
hosts: all
gather_facts: false # for testing the role fact gathering
roles:
- linux-system-roles.bootloader
tasks:
- name: Run in a block to clean up afterwards
block:
- name: Run with default parameters
include_role:
name: linux-system-roles.bootloader
rescue:
- name: Assert failure on s390x architecture
include_tasks: tasks/assert_fail_on_s390x.yml
3 changes: 3 additions & 0 deletions tests/tests_include_vars_from_parent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
name: caller
vars:
roletoinclude: linux-system-roles.bootloader
rescue:
- name: Assert failure on s390x architecture
include_tasks: tasks/assert_fail_on_s390x.yml
always:
- name: Cleanup
file:
Expand Down
3 changes: 3 additions & 0 deletions tests/tests_password.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
- name: Verify that user conf doesn't exist
assert:
that: not __bootloader_user_conf_stat.stat.exists
rescue:
- name: Assert failure on s390x architecture
include_tasks: tasks/assert_fail_on_s390x.yml
always:
- name: Remove boot loader password
vars:
Expand Down
3 changes: 3 additions & 0 deletions tests/tests_settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@
regex('set timeout=4')
register: __bootloader_default_grub_content
changed_when: false
rescue:
- name: Assert failure on s390x architecture
include_tasks: tasks/assert_fail_on_s390x.yml
always:
- name: Remove cloned kernels
command: >-
Expand Down
1 change: 1 addition & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
---
# ansible_facts required by the role
__bootloader_required_facts:
- architecture
- distribution
- distribution_major_version
- distribution_version
Expand Down
Loading