diff --git a/.ansible-lint b/.ansible-lint index 8ff1ec7e..73cc1507 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -22,3 +22,5 @@ exclude_paths: - examples/roles/ mock_roles: - linux-system-roles.ha_cluster +mock_modules: + - ansible.utils.update_fact diff --git a/.ostree/README.md b/.ostree/README.md new file mode 100644 index 00000000..f5e6931b --- /dev/null +++ b/.ostree/README.md @@ -0,0 +1,3 @@ +*NOTE*: The `*.txt` files are used by `get_ostree_data.sh` to create the lists +of packages, and to find other system roles used by this role. DO NOT use them +directly. diff --git a/.ostree/get_ostree_data.sh b/.ostree/get_ostree_data.sh new file mode 100755 index 00000000..7c325241 --- /dev/null +++ b/.ostree/get_ostree_data.sh @@ -0,0 +1,123 @@ +#!/bin/bash + +set -euo pipefail + +role_collection_dir="${ROLE_COLLECTION_DIR:-fedora/linux_system_roles}" +ostree_dir="${OSTREE_DIR:-"$(dirname "$(realpath "$0")")"}" + +if [ -z "${4:-}" ] || [ "${1:-}" = help ] || [ "${1:-}" = -h ]; then + cat < 0 diff --git a/tasks/set_vars.yml b/tasks/set_vars.yml index 818efd4e..7fab9e6e 100644 --- a/tasks/set_vars.yml +++ b/tasks/set_vars.yml @@ -5,6 +5,24 @@ when: __ha_cluster_required_facts | difference(ansible_facts.keys() | list) | length > 0 +- name: Ensure correct package manager for ostree systems + vars: + ostree_pkg_mgr: ansible.posix.rhel_rpm_ostree + ostree_booted_file: /run/ostree-booted + when: ansible_facts.pkg_mgr | d("") != ostree_pkg_mgr + block: + - name: Check if system is ostree + stat: + path: "{{ ostree_booted_file }}" + register: __ostree_booted_stat + + - name: Set package manager to use for ostree + ansible.utils.update_fact: + updates: + - path: ansible_facts.pkg_mgr + value: "{{ ostree_pkg_mgr }}" + when: __ostree_booted_stat.stat.exists + - name: Set platform/version specific variables include_vars: "{{ __vars_file }}" loop: diff --git a/tasks/test_setup.yml b/tasks/test_setup.yml index 51b4d6fc..7ba9094c 100644 --- a/tasks/test_setup.yml +++ b/tasks/test_setup.yml @@ -16,9 +16,38 @@ gather_subset: min when: "'distribution' not in ansible_facts" +- name: Ensure correct package manager for ostree systems + vars: + ostree_pkg_mgr: ansible.posix.rhel_rpm_ostree + ostree_booted_file: /run/ostree-booted + when: ansible_facts.pkg_mgr | d("") != ostree_pkg_mgr + block: + - name: Check if system is ostree + stat: + path: "{{ ostree_booted_file }}" + register: __ostree_booted_stat + + - name: Set package manager to use for ostree + ansible.utils.update_fact: + updates: + - path: ansible_facts.pkg_mgr + value: "{{ ostree_pkg_mgr }}" + when: __ostree_booted_stat.stat.exists + # Test systems may not have repositories available through subscriptions - name: Do not try to enable RHEL repositories set_fact: ha_cluster_enable_repos: false when: - ansible_distribution == 'RedHat' + +# HACK - test systems build ostree images with /usr/lib/passwd +# have to copy hacluster user to /etc/passwd +- name: >- + Copy nss-altfiles hacluster user to /etc/passwd so we can set the password + shell: | + if ! grep -q hacluster /etc/passwd && \ + grep -q hacluster /usr/lib/passwd; then + grep hacluster /usr/lib/passwd >> /etc/passwd + fi + when: ansible_facts.pkg_mgr | d() == "ansible.posix.rhel_rpm_ostree" diff --git a/tests/tests_cluster_basic_custom_fence_agents.yml b/tests/tests_cluster_basic_custom_fence_agents.yml index 2d42f58b..5d36ba61 100644 --- a/tests/tests_cluster_basic_custom_fence_agents.yml +++ b/tests/tests_cluster_basic_custom_fence_agents.yml @@ -17,6 +17,10 @@ name: linux-system-roles.ha_cluster tasks_from: test_setup.yml + - name: Skip test on ostree systems + meta: end_host + when: ansible_facts.pkg_mgr | d() == "ansible.posix.rhel_rpm_ostree" + - name: Ensure fence-agents-all is not installed package: name: fence-agents-all diff --git a/tests/tests_cluster_basic_custom_packages.yml b/tests/tests_cluster_basic_custom_packages.yml index d7203e46..4cc3f8c8 100644 --- a/tests/tests_cluster_basic_custom_packages.yml +++ b/tests/tests_cluster_basic_custom_packages.yml @@ -18,6 +18,10 @@ name: linux-system-roles.ha_cluster tasks_from: test_setup.yml + - name: Skip test on ostree systems + meta: end_host + when: ansible_facts.pkg_mgr | d() == "ansible.posix.rhel_rpm_ostree" + - name: Ensure extra package is not installed package: name: "{{ __test_extra_package }}" diff --git a/tests/tests_qdevice_all_options.yml b/tests/tests_qdevice_all_options.yml index 2cca3928..9ca809a8 100644 --- a/tests/tests_qdevice_all_options.yml +++ b/tests/tests_qdevice_all_options.yml @@ -5,6 +5,17 @@ vars_files: vars/main.yml tasks: + - name: Check if system is ostree + stat: + path: "{{ ostree_booted_file }}" + register: __ostree_booted_stat + vars: + ostree_booted_file: /run/ostree-booted + + - name: Skip test if ostree system + meta: end_host + when: __ostree_booted_stat.stat.exists + - name: Set qnetd address set_fact: __test_qnetd_address: "{{ diff --git a/tests/tests_qdevice_minimal.yml b/tests/tests_qdevice_minimal.yml index d5235b52..42378e46 100644 --- a/tests/tests_qdevice_minimal.yml +++ b/tests/tests_qdevice_minimal.yml @@ -5,6 +5,17 @@ vars_files: vars/main.yml tasks: + - name: Check if system is ostree + stat: + path: "{{ ostree_booted_file }}" + register: __ostree_booted_stat + vars: + ostree_booted_file: /run/ostree-booted + + - name: Skip test if ostree system + meta: end_host + when: __ostree_booted_stat.stat.exists + - name: Set qnetd address set_fact: __test_qnetd_address: "{{ diff --git a/tests/tests_qdevice_tls_kaptb_options.yml b/tests/tests_qdevice_tls_kaptb_options.yml index f24d299f..d3c39117 100644 --- a/tests/tests_qdevice_tls_kaptb_options.yml +++ b/tests/tests_qdevice_tls_kaptb_options.yml @@ -13,6 +13,24 @@ (ansible_play_hosts_all | length == 1) | ternary('localhost', ansible_play_hosts[0]) }}" + - name: Ensure correct package manager for ostree systems + vars: + ostree_pkg_mgr: ansible.posix.rhel_rpm_ostree + ostree_booted_file: /run/ostree-booted + when: ansible_facts.pkg_mgr | d("") != ostree_pkg_mgr + block: + - name: Check if system is ostree + stat: + path: "{{ ostree_booted_file }}" + register: __ostree_booted_stat + + - name: Set package manager to use for ostree + ansible.utils.update_fact: + updates: + - path: ansible_facts.pkg_mgr + value: "{{ ostree_pkg_mgr }}" + when: __ostree_booted_stat.stat.exists + # Install pcs so we can detect whether it supports tls and kaptb options - name: Install pcs package: diff --git a/tests/tests_qnetd.yml b/tests/tests_qnetd.yml index 2f753cd1..fa2cf754 100644 --- a/tests/tests_qnetd.yml +++ b/tests/tests_qnetd.yml @@ -8,6 +8,17 @@ ha_cluster_qnetd: present: true tasks: + - name: Check if system is ostree + stat: + path: "{{ ostree_booted_file }}" + register: __ostree_booted_stat + vars: + ostree_booted_file: /run/ostree-booted + + - name: Skip test if ostree system + meta: end_host + when: __ostree_booted_stat.stat.exists + - name: Run test tags: tests::verify block: diff --git a/tests/tests_qnetd_disabled.yml b/tests/tests_qnetd_disabled.yml index c5d79f03..4673d0f7 100644 --- a/tests/tests_qnetd_disabled.yml +++ b/tests/tests_qnetd_disabled.yml @@ -9,6 +9,17 @@ present: true start_on_boot: false tasks: + - name: Check if system is ostree + stat: + path: "{{ ostree_booted_file }}" + register: __ostree_booted_stat + vars: + ostree_booted_file: /run/ostree-booted + + - name: Skip test if ostree system + meta: end_host + when: __ostree_booted_stat.stat.exists + - name: Run test tags: tests::verify block: