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
1 change: 0 additions & 1 deletion tests/library

This file was deleted.

3 changes: 1 addition & 2 deletions tests/tasks/assert_node_options_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
- name: Run the role and check for errors
block:
- name: Run the role
include_role:
name: linux-system-roles.ha_cluster
include_tasks: tasks/run_role_with_clear_facts.yml

- name: Fail
fail:
Expand Down
18 changes: 12 additions & 6 deletions tests/tasks/fixture_psks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@
file: vars/rh_distros_vars.yml
when: __ha_cluster_is_rh_distro is not defined

- name: Set variable for crypto-policies PQC block
set_fact:
__need_crypto_policies_pqc: >-
{{ __ha_cluster_is_rh_distro | bool and (
(ansible_facts['distribution'] == 'RedHat' and
ansible_facts['distribution_version'] is version('9.7', '>=') and
ansible_facts['distribution_version'] is version('10', '<'))
or (ansible_facts['distribution'] != 'RedHat' and
ansible_facts['distribution_major_version'] is version('9', '=='))
) }}

- name: Check if the managed node needs crypto-policies to be able to use PQC
when:
- __ha_cluster_is_rh_distro | bool
- (ansible_facts["distribution"] == "RedHat" and ansible_facts["distribution_version"] is version("9.7", ">=")
and ansible_facts["distribution_version"] is version("10", "<"))
or (ansible_facts["distribution"] != "RedHat" and
ansible_facts['distribution_major_version'] is version("9", "=="))
when: __need_crypto_policies_pqc | bool
block:
# calling role with null will just return the current policy
- name: Get current crypto policy
Expand Down
39 changes: 39 additions & 0 deletions tests/tasks/run_role_with_clear_facts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
# Task file: save facts, clear_facts, run linux-system-roles.ha_cluster, then restore facts.
# Include this with include_tasks or import_tasks; ensure tests/library is in module search path.
# 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
# Output:
# - ansible_facts: merged saved ansible_facts with ansible_facts modified by the role, if any
- 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.ha_cluster
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.ha_cluster
tasks_from: "{{ __sr_tasks_from | default('main') }}"
public: "{{ __sr_public | default(false) }}"
when: __sr_failed_when | d(true)
7 changes: 3 additions & 4 deletions tests/template_qdevice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@
run_once: true # noqa: run_once[task]

- name: Run HA Cluster role
include_role:
name: linux-system-roles.ha_cluster
# variables for the role are supposed to be defined in a playbook which
# includes this task file
include_tasks: tasks/run_role_with_clear_facts.yml
# variables for the role are supposed to be defined in a playbook which
# includes this task file

# The role removed qnetd configuration
- name: Restore qnetd
Expand Down
6 changes: 3 additions & 3 deletions tests/template_sbd_all_options.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
- /etc/modules-load.d/softdog.conf

- name: Run HA Cluster role
include_role:
name: linux-system-roles.ha_cluster
public: true
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__sr_public: true

- name: Slurp generated SBD watchdog blocklist file
slurp:
Expand Down
6 changes: 3 additions & 3 deletions tests/tests_bootc_e2e_cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
when: not __bootc_validation | d(false)
block:
- name: Run HA Cluster role
include_role:
name: linux-system-roles.ha_cluster
public: true
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__sr_public: true
when: not __bootc_validation | d(false)

- name: Create QEMU deployment during bootc end-to-end test
Expand Down
6 changes: 3 additions & 3 deletions tests/tests_bootc_e2e_qnetd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
when: not __bootc_validation | d(false)
block:
- name: Run HA Cluster role
include_role:
name: linux-system-roles.ha_cluster
public: true
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__sr_public: true
when: not __bootc_validation | d(false)

- name: Create QEMU deployment during bootc end-to-end test
Expand Down
5 changes: 2 additions & 3 deletions tests/tests_cib_acls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
tasks_from: test_setup.yml

- name: Run HA Cluster role
include_role:
name: linux-system-roles.ha_cluster
public: true
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__sr_public: true
ha_cluster_cluster_name: test-cluster
ha_cluster_manage_firewall: true
ha_cluster_manage_selinux: true
Expand Down
5 changes: 2 additions & 3 deletions tests/tests_cib_alerts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
tasks_from: test_setup.yml

- name: Run HA Cluster role
include_role:
name: linux-system-roles.ha_cluster
public: true
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__sr_public: true
ha_cluster_cluster_name: test-cluster
ha_cluster_manage_firewall: true
ha_cluster_manage_selinux: true
Expand Down
6 changes: 3 additions & 3 deletions tests/tests_cib_constraints_create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,9 @@
tasks_from: test_setup.yml

- name: Run HA Cluster role
include_role:
name: linux-system-roles.ha_cluster
public: true
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__sr_public: true

- name: Fetch cluster versions of cluster components
include_tasks: tasks/fetch_versions.yml
Expand Down
6 changes: 3 additions & 3 deletions tests/tests_cib_constraints_create_and_load_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@
- __constraints_capability in __test_pcs_capabilities
block:
- name: Run HA Cluster role
include_role:
name: linux-system-roles.ha_cluster
public: true
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__sr_public: true

- name: Check firewall and selinux state
include_tasks: tasks/check_firewall_selinux.yml
Expand Down
5 changes: 2 additions & 3 deletions tests/tests_cib_node_attributes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
| ternary('localhost', ansible_play_hosts[0]) }}"

- name: Run HA Cluster role
include_role:
name: linux-system-roles.ha_cluster
public: true
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__sr_public: true
ha_cluster_cluster_name: test-cluster
ha_cluster_manage_firewall: true
ha_cluster_manage_selinux: true
Expand Down
6 changes: 3 additions & 3 deletions tests/tests_cib_properties_empty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
tasks_from: test_setup.yml

- name: Run HA Cluster role
include_role:
name: linux-system-roles.ha_cluster
public: true
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__sr_public: true

- name: Fetch versions of cluster components
include_tasks: tasks/fetch_versions.yml
Expand Down
6 changes: 3 additions & 3 deletions tests/tests_cib_properties_one_set.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
tasks_from: test_setup.yml

- name: Run HA Cluster role
include_role:
name: linux-system-roles.ha_cluster
public: true
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__sr_public: true

- name: Fetch cluster versions of cluster components
include_tasks: tasks/fetch_versions.yml
Expand Down
6 changes: 3 additions & 3 deletions tests/tests_cib_resources_create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,9 @@
tasks_from: test_setup.yml

- name: Run HA Cluster role
include_role:
name: linux-system-roles.ha_cluster
public: true
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__sr_public: true

- name: Fetch cluster versions of cluster components
include_tasks: tasks/fetch_versions.yml
Expand Down
6 changes: 3 additions & 3 deletions tests/tests_cib_resources_create_and_load_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,9 @@
}}
block:
- name: Run HA Cluster role
include_role:
name: linux-system-roles.ha_cluster
public: true
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__sr_public: true

- name: Print facts
debug:
Expand Down
6 changes: 3 additions & 3 deletions tests/tests_cib_rsc_op_defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@
tasks_from: test_setup.yml

- name: Run HA Cluster role
include_role:
name: linux-system-roles.ha_cluster
public: true
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__sr_public: true

- name: Fetch versions of cluster components
include_tasks: tasks/fetch_versions.yml
Expand Down
5 changes: 2 additions & 3 deletions tests/tests_cib_stonith_levels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
| ternary('localhost', ansible_play_hosts[0]) }}"

- name: Run HA Cluster role
include_role:
name: linux-system-roles.ha_cluster
public: true
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__sr_public: true
ha_cluster_cluster_name: test-cluster
ha_cluster_manage_firewall: true
ha_cluster_manage_selinux: true
Expand Down
12 changes: 4 additions & 8 deletions tests/tests_cib_stonith_levels_validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
- name: Check that target is specified
block:
- name: Run HA Cluster role 1
include_role:
name: linux-system-roles.ha_cluster
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
ha_cluster_cluster_name: test-cluster
ha_cluster_stonith_levels:
Expand All @@ -36,8 +35,7 @@
- name: Check that exactly one target is specified
block:
- name: Run HA Cluster role 2
include_role:
name: linux-system-roles.ha_cluster
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
ha_cluster_cluster_name: test-cluster
ha_cluster_stonith_levels:
Expand All @@ -58,8 +56,7 @@
- name: Check that level is specified
block:
- name: Run HA Cluster role 3
include_role:
name: linux-system-roles.ha_cluster
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
ha_cluster_cluster_name: test-cluster
ha_cluster_stonith_levels:
Expand All @@ -77,8 +74,7 @@
- name: Check that level is correct
block:
- name: Run HA Cluster role 4
include_role:
name: linux-system-roles.ha_cluster
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
ha_cluster_cluster_name: test-cluster
ha_cluster_stonith_levels:
Expand Down
5 changes: 2 additions & 3 deletions tests/tests_cib_utilization.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
| ternary('localhost', ansible_play_hosts[0]) }}"

- name: Run HA Cluster role
include_role:
name: linux-system-roles.ha_cluster
public: true
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__sr_public: true
ha_cluster_cluster_name: test-cluster
ha_cluster_manage_firewall: true
ha_cluster_manage_selinux: true
Expand Down
6 changes: 3 additions & 3 deletions tests/tests_cluster_advanced_knet_full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
| regex_findall('\\S+') | batch(2) | first | flatten }}"

- name: Run HA Cluster role
include_role:
name: linux-system-roles.ha_cluster
public: true
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__sr_public: true

- name: Fetch cluster versions of cluster components
include_tasks: tasks/fetch_versions.yml
Expand Down
6 changes: 3 additions & 3 deletions tests/tests_cluster_advanced_knet_implicit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
tasks_from: test_setup.yml

- name: Run HA Cluster role
include_role:
name: linux-system-roles.ha_cluster
public: true
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__sr_public: true

- name: Fetch cluster versions of cluster components
include_tasks: tasks/fetch_versions.yml
Expand Down
6 changes: 3 additions & 3 deletions tests/tests_cluster_advanced_udp_full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
tasks_from: test_setup.yml

- name: Run HA Cluster role
include_role:
name: linux-system-roles.ha_cluster
public: true
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__sr_public: true

- name: Fetch cluster versions of cluster components
include_tasks: tasks/fetch_versions.yml
Expand Down
6 changes: 3 additions & 3 deletions tests/tests_cluster_basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
- /var/lib/pcsd/pcsd.crt

- name: Run HA Cluster role
include_role:
name: linux-system-roles.ha_cluster
public: true
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__sr_public: true

- name: Fetch cluster versions of cluster components
include_tasks: tasks/fetch_versions.yml
Expand Down
Loading
Loading