From 927ffeebd6af6720cdc295448e935073709fddf3 Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Mon, 30 Oct 2023 17:13:43 -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 --- .ansible-lint | 2 + .ostree/README.md | 3 + .ostree/get_ostree_data.sh | 123 +++++++++++++++++++++++++++++++ .ostree/packages-runtime.txt | 4 + .sanity-ansible-ignore-2.12.txt | 1 + .sanity-ansible-ignore-2.13.txt | 1 + .sanity-ansible-ignore-2.14.txt | 1 + .sanity-ansible-ignore-2.15.txt | 1 + .sanity-ansible-ignore-2.9.txt | 1 + README-ostree.md | 66 +++++++++++++++++ README.md | 18 +++++ meta/collection-requirements.yml | 5 ++ tasks/set_vars.yml | 18 +++++ tests/tests_ssh_reboot.yml | 15 ++++ vars/main.yml | 5 +- 15 files changed, 263 insertions(+), 1 deletion(-) create mode 100644 .ostree/README.md create mode 100755 .ostree/get_ostree_data.sh create mode 100644 .ostree/packages-runtime.txt create mode 100644 .sanity-ansible-ignore-2.12.txt create mode 100644 .sanity-ansible-ignore-2.13.txt create mode 100644 .sanity-ansible-ignore-2.14.txt create mode 100644 .sanity-ansible-ignore-2.15.txt create mode 100644 .sanity-ansible-ignore-2.9.txt create mode 100644 README-ostree.md create mode 100644 meta/collection-requirements.yml diff --git a/.ansible-lint b/.ansible-lint index 5dbc810..1190c95 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -22,3 +22,5 @@ exclude_paths: - examples/roles/ mock_roles: - linux-system-roles.kdump +mock_modules: + - ansible.utils.update_fact diff --git a/.ostree/README.md b/.ostree/README.md new file mode 100644 index 0000000..f5e6931 --- /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 0000000..7c32524 --- /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 + +- 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 diff --git a/tests/tests_ssh_reboot.yml b/tests/tests_ssh_reboot.yml index 3eddd28..52e9023 100644 --- a/tests/tests_ssh_reboot.yml +++ b/tests/tests_ssh_reboot.yml @@ -95,6 +95,21 @@ - ansible_distribution_major_version == '6' - kdump_test_ssh_server_outside == inventory_hostname + - name: Skip the test on ostree systems - does not like the dracut rebuild + 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: Skip the test on ostree systems + meta: end_host + when: __ostree_booted_stat.stat.exists + - name: Run the role and reboot if necessary include_role: name: linux-system-roles.kdump diff --git a/vars/main.yml b/vars/main.yml index 88fb139..6782ff5 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -6,7 +6,10 @@ __kdump_ssh_server_location: "{{ kdump_target.location | else kdump_ssh_server }}" __kdump_packages: - - "kexec-tools" + - grubby + - iproute # for fact gathering for ip facts + - kexec-tools + - openssh-clients __kdump_required_facts: - all_ipv4_addresses