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_cleanup_qnetd.yml b/tasks/test_cleanup_qnetd.yml index 7ce4af56..4f513607 100644 --- a/tasks/test_cleanup_qnetd.yml +++ b/tasks/test_cleanup_qnetd.yml @@ -11,8 +11,10 @@ name: - corosync-qnetd state: absent + when: ansible_facts.pkg_mgr | d() != "ansible.posix.rhel_rpm_ostree" - name: Make sure qnetd config files are not present file: path: /etc/corosync/qnetd state: absent + when: ansible_facts.pkg_mgr | d() != "ansible.posix.rhel_rpm_ostree" diff --git a/tasks/test_setup.yml b/tasks/test_setup.yml index 51b4d6fc..51126d35 100644 --- a/tasks/test_setup.yml +++ b/tasks/test_setup.yml @@ -16,9 +16,42 @@ 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 +# also coroqnetd user for nss db ownership +- name: >- + Copy nss-altfiles ha_cluster users to /etc/passwd + shell: | + for username in hacluster coroqnetd; do + if ! grep -q "^$username" /etc/passwd && \ + grep -q "^$username" /usr/lib/passwd; then + grep "^$username" /usr/lib/passwd >> /etc/passwd + fi + done + when: ansible_facts.pkg_mgr | d() == "ansible.posix.rhel_rpm_ostree" + changed_when: true diff --git a/tests/tests_cluster_basic_custom_fence_agents.yml b/tests/tests_cluster_basic_custom_fence_agents.yml index 2d42f58b..8055834d 100644 --- a/tests/tests_cluster_basic_custom_fence_agents.yml +++ b/tests/tests_cluster_basic_custom_fence_agents.yml @@ -21,6 +21,7 @@ package: name: fence-agents-all state: absent + when: ansible_facts.pkg_mgr | d() != "ansible.posix.rhel_rpm_ostree" - name: Run HA Cluster role include_role: @@ -29,12 +30,14 @@ - name: Get packages status package_facts: + when: ansible_facts.pkg_mgr | d() != "ansible.posix.rhel_rpm_ostree" - name: Check installed fence-agents packages assert: that: - "'fence-agents-all' not in ansible_facts.packages" - "'fence-agents-ipmilan' in ansible_facts.packages" + when: ansible_facts.pkg_mgr | d() != "ansible.posix.rhel_rpm_ostree" - name: Check cluster status include_tasks: tasks/assert_cluster_running.yml 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_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: