From e903bc1b20943d6bc959ab1bb0313bb1a333d162 Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Tue, 10 Oct 2023 13:29:45 -0600 Subject: [PATCH] feat: support for ostree systems Feature: Allow running and testing the role with ostree managed nodes. Reason: We have users who want to use the role to manage ostree systems. Result: Users can use the role to manage ostree managed nodes. Signed-off-by: Rich Megginson --- .ostree/README.md | 3 + .ostree/get_ostree_data.sh | 113 ++++++++++++++++++++++++++ .ostree/packages-runtime.txt | 1 + .ostree/packages-testing-CentOS-8.txt | 1 + .ostree/packages-testing-CentOS-9.txt | 1 + .ostree/packages-testing-Fedora.txt | 1 + .ostree/packages-testing-RedHat-8.txt | 1 + .ostree/packages-testing-RedHat-9.txt | 1 + .ostree/packages-testing.txt | 1 + README.md | 68 ++++++++++++++++ meta/collection-requirements.yml | 3 + tasks/firewalld.yml | 18 ++++ tests/tests_reload_on_reset.yml | 18 ++++ tests/tests_startup_conflicts.yml | 18 ++++ 14 files changed, 248 insertions(+) create mode 100644 .ostree/README.md create mode 100755 .ostree/get_ostree_data.sh create mode 100644 .ostree/packages-runtime.txt create mode 100644 .ostree/packages-testing-CentOS-8.txt create mode 100644 .ostree/packages-testing-CentOS-9.txt create mode 100644 .ostree/packages-testing-Fedora.txt create mode 100644 .ostree/packages-testing-RedHat-8.txt create mode 100644 .ostree/packages-testing-RedHat-9.txt create mode 100644 .ostree/packages-testing.txt create mode 100644 meta/collection-requirements.yml 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..cbc502fb --- /dev/null +++ b/.ostree/get_ostree_data.sh @@ -0,0 +1,113 @@ +#!/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 ] || [ x"${1:-}" = x-h ]; then + cat < 0 +- name: Ensure correct package manager for ostree systems + vars: + ostree_pkg_mgr: ansible.posix.rhel_rpm_ostree + when: ansible_facts.pkg_mgr | d("") != ostree_pkg_mgr + block: + - name: Check if system is ostree + ansible.posix.rhel_facts: + register: __rhel_facts + + - name: Set package manager to use for ostree + set_fact: + ansible_facts: "{{ ansible_facts | + combine(new_facts, recursive=True) }}" + vars: + new_facts: + pkg_mgr: "{{ ostree_pkg_mgr }}" + when: __rhel_facts['ansible_facts'].get('pkg_mgr') == ostree_pkg_mgr + - name: Install firewalld package: name: "{{ __firewall_packages_base }}" diff --git a/tests/tests_reload_on_reset.yml b/tests/tests_reload_on_reset.yml index a23a3c51..89a50710 100644 --- a/tests/tests_reload_on_reset.yml +++ b/tests/tests_reload_on_reset.yml @@ -9,6 +9,24 @@ - ansible_distribution in ['RedHat', 'CentOS'] - ansible_distribution_major_version | int < 8 tasks: + - name: Ensure correct package manager for ostree systems + vars: + ostree_pkg_mgr: ansible.posix.rhel_rpm_ostree + when: ansible_facts.pkg_mgr | d("") != ostree_pkg_mgr + block: + - name: Check if system is ostree + ansible.posix.rhel_facts: + register: __rhel_facts + + - name: Set package manager to use for ostree + set_fact: + ansible_facts: "{{ ansible_facts | + combine(new_facts, recursive=True) }}" + vars: + new_facts: + pkg_mgr: "{{ ostree_pkg_mgr }}" + when: __rhel_facts['ansible_facts'].get('pkg_mgr') == ostree_pkg_mgr + - name: Install podman package: name: podman diff --git a/tests/tests_startup_conflicts.yml b/tests/tests_startup_conflicts.yml index eac699e6..c232817c 100644 --- a/tests/tests_startup_conflicts.yml +++ b/tests/tests_startup_conflicts.yml @@ -16,6 +16,24 @@ include_role: name: linux-system-roles.firewall + - name: Ensure correct package manager for ostree systems + vars: + ostree_pkg_mgr: ansible.posix.rhel_rpm_ostree + when: ansible_facts.pkg_mgr | d("") != ostree_pkg_mgr + block: + - name: Check if system is ostree + ansible.posix.rhel_facts: + register: __rhel_facts + + - name: Set package manager to use for ostree + set_fact: + ansible_facts: "{{ ansible_facts | + combine(new_facts, recursive=True) }}" + vars: + new_facts: + pkg_mgr: "{{ ostree_pkg_mgr }}" + when: __rhel_facts['ansible_facts'].get('pkg_mgr') == ostree_pkg_mgr + - name: Install conflicting service package: name: nftables