Debian Codegraph @

test/integration/targets/module_utils_facts.system.selinux/tasks/main.yml

raw
1 - name: check selinux config
2 shell: |
3 command -v getenforce &&
4 getenforce | grep -E 'Enforcing|Permissive'
5 ignore_errors: yes
6 register: selinux_state
7
8 - name: explicitly collect selinux facts
9 setup:
10 gather_subset:
11 - '!all'
12 - '!any'
13 - selinux
14 register: selinux_facts
15
16 - set_fact:
17 selinux_policytype: "unknown"
18
19 - name: check selinux policy type
20 shell: grep '^SELINUXTYPE=' /etc/selinux/config | cut -d'=' -f2
21 ignore_errors: yes
22 register: r
23
24 - set_fact:
25 selinux_policytype: "{{ r.stdout_lines[0] | trim }}"
26 when: r is success and r.stdout_lines is truthy
27
28 - assert:
29 that:
30 - selinux_facts is success and selinux_facts.ansible_facts.ansible_selinux is defined
31 - (selinux_facts.ansible_facts.ansible_selinux.status in ['disabled', 'Missing selinux Python library'] if selinux_state is not success else True)
32 - (selinux_facts.ansible_facts.ansible_selinux.status == 'enabled' if selinux_state is success else True)
33 - (selinux_facts.ansible_facts.ansible_selinux.mode in ['enforcing', 'permissive'] if selinux_state is success else True)
34 - (selinux_facts.ansible_facts.ansible_selinux.type == selinux_policytype if selinux_state is success else True)
35
36 - name: run selinux tests
37 include_tasks: selinux.yml
38 when: selinux_state is success