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..d0a03a3d --- /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 ] || [ "${1:-}" = -h ]; then + cat < 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: 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..93dec5f4 100644 --- a/tests/tests_reload_on_reset.yml +++ b/tests/tests_reload_on_reset.yml @@ -9,6 +9,26 @@ - 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 + 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 + set_fact: + ansible_facts: "{{ ansible_facts | + combine(new_facts, recursive=True) }}" + vars: + new_facts: + pkg_mgr: "{{ ostree_pkg_mgr }}" + when: __ostree_booted_stat.stat.exists + - name: Install podman package: name: podman diff --git a/tests/tests_startup_conflicts.yml b/tests/tests_startup_conflicts.yml index eac699e6..1e32be1e 100644 --- a/tests/tests_startup_conflicts.yml +++ b/tests/tests_startup_conflicts.yml @@ -16,6 +16,26 @@ include_role: name: linux-system-roles.firewall + - 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 + set_fact: + ansible_facts: "{{ ansible_facts | + combine(new_facts, recursive=True) }}" + vars: + new_facts: + pkg_mgr: "{{ ostree_pkg_mgr }}" + when: __ostree_booted_stat.stat.exists + - name: Install conflicting service package: name: nftables