diff --git a/.ansible-lint b/.ansible-lint index 511a183..395fa4a 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -23,5 +23,3 @@ exclude_paths: mock_roles: - linux-system-roles.postgresql - linux-system-roles.certificate -mock_modules: - - ansible.utils.update_fact diff --git a/.ostree/get_ostree_data.sh b/.ostree/get_ostree_data.sh index 7c32524..cec08b0 100755 --- a/.ostree/get_ostree_data.sh +++ b/.ostree/get_ostree_data.sh @@ -2,7 +2,6 @@ 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 @@ -29,7 +28,7 @@ if [ "$pkgtype" = testing ]; then fi get_rolepath() { - local ostree_dir role rolesdir roles_parent_dir + local ostree_dir role rolesdir roles_parent_dir coll_path pth ostree_dir="$1" role="$2" roles_parent_dir="$(dirname "$(dirname "$ostree_dir")")" @@ -47,16 +46,22 @@ get_rolepath() { fi done # look elsewhere - if [ -n "${ANSIBLE_COLLECTIONS_PATHS:-}" ]; then - for pth in ${ANSIBLE_COLLECTIONS_PATHS//:/ }; do - rolesdir="$pth/ansible_collections/$role_collection_dir/roles/$role/.ostree" - if [ -d "$rolesdir" ]; then - echo "$rolesdir" - return 0 - fi + coll_path="${ANSIBLE_COLLECTIONS_PATH:-}" + if [ -z "$coll_path" ]; then + coll_path="${ANSIBLE_COLLECTIONS_PATHS:-}" + fi + if [ -n "${coll_path}" ]; then + for pth in ${coll_path//:/ }; do + for rolesdir in "$pth"/ansible_collections/*/*_system_roles/roles/"$role"/.ostree; do + if [ -d "$rolesdir" ]; then + echo "$rolesdir" + return 0 + fi + done done fi - return 1 + 1>&2 echo ERROR - could not find role "$role" - please use ANSIBLE_COLLECTIONS_PATH + exit 2 } get_packages() { @@ -75,6 +80,10 @@ get_packages() { roles="$(cat "$rolefile")" for role in $roles; do rolepath="$(get_rolepath "$ostree_dir" "$role")" + if [ -z "$rolepath" ]; then + 1>&2 echo ERROR - could not find role "$role" - please use ANSIBLE_COLLECTIONS_PATH + exit 2 + fi get_packages "$rolepath" done fi diff --git a/.ostree/packages-runtime-CentOS.txt b/.ostree/packages-runtime-CentOS-8.txt similarity index 100% rename from .ostree/packages-runtime-CentOS.txt rename to .ostree/packages-runtime-CentOS-8.txt diff --git a/.ostree/packages-runtime-CentOS-9.txt b/.ostree/packages-runtime-CentOS-9.txt new file mode 100644 index 0000000..dd725ef --- /dev/null +++ b/.ostree/packages-runtime-CentOS-9.txt @@ -0,0 +1 @@ +postgresql-server diff --git a/.ostree/packages-runtime.txt b/.ostree/packages-runtime.txt deleted file mode 100644 index e69de29..0000000 diff --git a/meta/collection-requirements.yml b/meta/collection-requirements.yml index 2be1ccd..8001a36 100644 --- a/meta/collection-requirements.yml +++ b/meta/collection-requirements.yml @@ -1,5 +1,4 @@ --- collections: - ansible.posix - - ansible.utils - fedora.linux_system_roles diff --git a/tasks/main.yml b/tasks/main.yml index 0506775..856a216 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -40,10 +40,12 @@ package: name: "{{ __actual_packages }}" state: present + use: "{{ (__postgresql_is_ostree | d(false)) | + ternary('ansible.posix.rhel_rpm_ostree', omit) }}" when: __actual_packages | length > 0 vars: __actual_packages: "{{ - (ansible_facts.pkg_mgr | d() == 'ansible.posix.rhel_rpm_ostree') | + (__postgresql_is_ostree | d(false)) | ternary(__postgresql_packages | reject('match', '^@'), __postgresql_packages) | list }}" diff --git a/tasks/set_vars.yml b/tasks/set_vars.yml index d99acda..fe1745d 100644 --- a/tasks/set_vars.yml +++ b/tasks/set_vars.yml @@ -5,23 +5,17 @@ when: __postgresql_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 +- name: Determine if system is ostree and set flag + when: not __postgresql_is_ostree is defined block: - name: Check if system is ostree stat: - path: "{{ ostree_booted_file }}" + path: /run/ostree-booted 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 flag to indicate system is ostree + set_fact: + __postgresql_is_ostree: "{{ __ostree_booted_stat.stat.exists }}" - name: Set platform/version specific variables include_vars: "{{ __vars_file }}" diff --git a/tests/tasks/clean_instance.yml b/tests/tasks/clean_instance.yml index 449962a..2139e14 100644 --- a/tests/tasks/clean_instance.yml +++ b/tests/tasks/clean_instance.yml @@ -10,7 +10,7 @@ vars: __cleanup_packages: "{{ __postgresql_packages + ['postgresql', 'postgresql-private-libs'] }}" - when: ansible_facts.pkg_mgr | d() != "ansible.posix.rhel_rpm_ostree" + when: not __postgresql_is_ostree | d(false) - name: Remove data directory file: