validations-common/validations_common/roles/check_selinux_mode/tasks/main.yml
Gael Chamoulaud (Strider) a76b981cf6
[check_selinux_mode] Add role documentation in sphinx
This patch adds the documentation directly in the sphinx role
documentation index. All variables have been commented with a proper
description to be included automatically in the sphinx build.

This patch also fixes the facts gathering by being sure we get only the
needed facts.

Change-Id: Ifbe7bd73559b05f6655bfd396029c22345b75f4c
Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
2021-06-29 10:55:10 +02:00

39 lines
1.1 KiB
YAML

---
- name: Ensure we get needed facts
setup:
gather_subset:
- '!all'
- '!any'
- '!min'
- distribution
- os_family
- name: Get current SELinux mode
command: getenforce
become: true
register: sestatus
changed_when: false
when:
- "ansible_os_family is defined and ansible_os_family == 'RedHat'"
- name: Check sestatus
block:
- name: Fail if SELinux is not in Enforced mode (RHEL)
fail:
msg: >-
SELinux is running in {{ sestatus.stdout }} mode on the Undercloud.
Ensure that SELinux is enabled and running in Enforcing mode.
when:
- "sestatus.stdout != 'Enforcing'"
- "ansible_distribution == 'RedHat'"
- name: Warn if SELinux is not in Enforced mode (CentOS)
warn:
msg: >-
SELinux is running in {{ sestatus.stdout }} mode on the Undercloud.
Ensure that SELinux is enabled and running in Enforcing mode.
when:
- "sestatus.stdout != 'Enforcing'"
- "ansible_distribution == 'CentOS'"
when: sestatus.stdout is defined