summaryrefslogtreecommitdiffstats
path: root/test/integration
diff options
context:
space:
mode:
authorAbhijeet Kasurde <akasurde@redhat.com>2021-03-01 20:11:09 +0100
committerGitHub <noreply@github.com>2021-03-01 20:11:09 +0100
commit6cb324bb0e8fd8b85993e825dfef68d79156c2f0 (patch)
treed015c0e518f35f2fa8d4ace3d41639869157b382 /test/integration
parentFixes for ansible-console usability (#73665) (diff)
downloadansible-6cb324bb0e8fd8b85993e825dfef68d79156c2f0.tar.xz
ansible-6cb324bb0e8fd8b85993e825dfef68d79156c2f0.zip
selinux: return selinux_getpolicytype facts (#73609)
* selinux: return selinux_getpolicytype facts Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com> * add basic selinux facts tests * fix selinux facts test when selinux missing Co-authored-by: Matt Davis <mrd@redhat.com>
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/targets/module_utils_selinux/aliases5
-rw-r--r--test/integration/targets/module_utils_selinux/tasks/main.yml27
2 files changed, 32 insertions, 0 deletions
diff --git a/test/integration/targets/module_utils_selinux/aliases b/test/integration/targets/module_utils_selinux/aliases
index a6dafcf8cd..aab3ff52eb 100644
--- a/test/integration/targets/module_utils_selinux/aliases
+++ b/test/integration/targets/module_utils_selinux/aliases
@@ -1 +1,6 @@
shippable/posix/group1
+skip/aix
+skip/osx
+skip/macos
+skip/freebsd
+skip/docker
diff --git a/test/integration/targets/module_utils_selinux/tasks/main.yml b/test/integration/targets/module_utils_selinux/tasks/main.yml
index ed2d4f0163..c599377b64 100644
--- a/test/integration/targets/module_utils_selinux/tasks/main.yml
+++ b/test/integration/targets/module_utils_selinux/tasks/main.yml
@@ -5,6 +5,33 @@
ignore_errors: yes
register: selinux_state
+- name: explicitly collect selinux facts
+ setup:
+ gather_subset:
+ - '!all'
+ - '!any'
+ - selinux
+ register: selinux_facts
+
+- set_fact:
+ selinux_policytype: "unknown"
+
+- name: check selinux policy type
+ shell: grep '^SELINUXTYPE=' /etc/selinux/config | cut -d'=' -f2
+ register: r
+
+- set_fact:
+ selinux_policytype: "{{ r.stdout_lines[0] }}"
+ when: r.changed
+
+- assert:
+ that:
+ - selinux_facts is success and selinux_facts.ansible_facts.ansible_selinux is defined
+ - (selinux_facts.ansible_facts.ansible_selinux.status in ['disabled', 'Missing selinux Python library'] if selinux_state is not success else True)
+ - (selinux_facts.ansible_facts.ansible_selinux.status == 'enabled' if selinux_state is success else True)
+ - (selinux_facts.ansible_facts.ansible_selinux.mode in ['enforcing', 'permissive'] if selinux_state is success else True)
+ - (selinux_facts.ansible_facts.ansible_selinux.type == selinux_policytype if selinux_state is success else True)
+
- name: run selinux tests
include_tasks: selinux.yml
when: selinux_state is success