From 00088b16ceac67600fdb9a5b7af7da3de5ad9f1c Mon Sep 17 00:00:00 2001 From: Marcus Klein Date: Thu, 21 Nov 2024 15:25:42 +0100 Subject: [PATCH] Use variables from ansible_facts in _common role to allow ANSIBLE_INJECT_FACT_VARS to become false Signed-off-by: Marcus Klein --- roles/_common/meta/argument_specs.yml | 4 ++-- roles/_common/tasks/preflight.yml | 2 +- roles/_common/vars/main.yml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/roles/_common/meta/argument_specs.yml b/roles/_common/meta/argument_specs.yml index fd2fa3e80..34a391ecf 100644 --- a/roles/_common/meta/argument_specs.yml +++ b/roles/_common/meta/argument_specs.yml @@ -77,8 +77,8 @@ argument_specs: options: _common_dependencies: description: "Package dependencies to install" - default: "{% if (ansible_pkg_mgr == 'apt') %}\ - {{ ('python-apt' if ansible_python_version is version('3', '<') else 'python3-apt') }} + default: "{% if (ansible_facts['pkg_mgr'] == 'apt') %}\ + {{ ('python-apt' if ansible_facts['python_version'] is version('3', '<') else 'python3-apt') }} {% else %}\ {% endif %}" _common_web_listen_address: diff --git a/roles/_common/tasks/preflight.yml b/roles/_common/tasks/preflight.yml index 6ea26f62a..5f58fe48e 100644 --- a/roles/_common/tasks/preflight.yml +++ b/roles/_common/tasks/preflight.yml @@ -43,7 +43,7 @@ - name: Assert usage of systemd as an init system ansible.builtin.assert: - that: ansible_service_mgr == 'systemd' + that: ansible_facts['service_mgr'] == 'systemd' msg: "This module only works with systemd" tags: - "{{ ansible_parent_role_names | first | regex_replace(ansible_collection_name ~ '.', '') }}" diff --git a/roles/_common/vars/main.yml b/roles/_common/vars/main.yml index 8d8beb8b8..d487b4ad7 100644 --- a/roles/_common/vars/main.yml +++ b/roles/_common/vars/main.yml @@ -10,8 +10,8 @@ _common_selinux_port: "" _common_service_name: "{{ __common_parent_role_short_name }}" _common_system_user: "" _common_system_group: "" -_common_dependencies: "{% if (ansible_pkg_mgr == 'apt') %}\ - {{ ('python-apt' if ansible_python_version is version('3', '<') else 'python3-apt') }} +_common_dependencies: "{% if (ansible_facts['pkg_mgr'] == 'apt') %}\ + {{ ('python-apt' if ansible_facts['python_version'] is version('3', '<') else 'python3-apt') }} {% else %}\ {% endif %}" _common_binary_unarchive_opts: ""