From fbd630d3eb955e3bc43b053e9a49be2653aa1a17 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Wed, 26 Jan 2022 22:00:36 +0100 Subject: [PATCH] add package handling for rh7 and rh8 --- defaults/main.yml | 2 +- molecule/centos7/tests/test_default.py | 1 + molecule/rocky8/tests/test_default.py | 3 ++- tasks/main.yml | 15 ++++++++++++++- tasks/overwrites.yml | 5 +++++ vars/redhat-7.yml | 4 ++++ vars/redhat-8.yml | 4 ++++ 7 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 tasks/overwrites.yml create mode 100644 vars/redhat-7.yml create mode 100644 vars/redhat-8.yml diff --git a/defaults/main.yml b/defaults/main.yml index 97ee6de..1ec3a4e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,6 +1,6 @@ --- selinux_packages: - - policycoreutils-python + - policycoreutils-python selinux_policy: "targeted" selinux_state: "{{ ansible_selinux.config_mode }}" diff --git a/molecule/centos7/tests/test_default.py b/molecule/centos7/tests/test_default.py index 8f36c72..ddbd6dd 100644 --- a/molecule/centos7/tests/test_default.py +++ b/molecule/centos7/tests/test_default.py @@ -9,4 +9,5 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( def test_selinux_setup(host): assert host.command.check_output("/usr/sbin/getenforce") == "Enforcing" + assert host.package("libselinux-python").is_installed assert host.package("policycoreutils-python").is_installed diff --git a/molecule/rocky8/tests/test_default.py b/molecule/rocky8/tests/test_default.py index 8f36c72..f475691 100644 --- a/molecule/rocky8/tests/test_default.py +++ b/molecule/rocky8/tests/test_default.py @@ -9,4 +9,5 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( def test_selinux_setup(host): assert host.command.check_output("/usr/sbin/getenforce") == "Enforcing" - assert host.package("policycoreutils-python").is_installed + assert host.package("libselinux-python").is_installed + assert host.package("policycoreutils-python-utils").is_installed diff --git a/tasks/main.yml b/tasks/main.yml index 6422299..b86f8ff 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,2 +1,15 @@ --- -- import_tasks: setup.yml +- include_vars: "{{ var_files }}" + vars: + var_files: "{{ lookup('first_found', params, errors='ignore') }}" + params: + files: + - "{{ ansible_lsb.id | default('') | lower }}.yml" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version }}.yml" + - "{{ ansible_os_family | lower }}.yml" + paths: + - "vars" + when: var_files + +- include_tasks: overwrites.yml +- include_tasks: setup.yml diff --git a/tasks/overwrites.yml b/tasks/overwrites.yml new file mode 100644 index 0000000..eadfc6b --- /dev/null +++ b/tasks/overwrites.yml @@ -0,0 +1,5 @@ +--- +- name: Define selinux_packages + set_fact: + selinux_packages: "{{ __selinux_packages }}" + when: selinux_packages is not defined diff --git a/vars/redhat-7.yml b/vars/redhat-7.yml new file mode 100644 index 0000000..3dd2cff --- /dev/null +++ b/vars/redhat-7.yml @@ -0,0 +1,4 @@ +--- +__selinux_packages: + - libselinux-python + - policycoreutils-python diff --git a/vars/redhat-8.yml b/vars/redhat-8.yml new file mode 100644 index 0000000..a133d2f --- /dev/null +++ b/vars/redhat-8.yml @@ -0,0 +1,4 @@ +--- +__selinux_packages: + - libselinux-python + - policycoreutils-python-utils