# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol,multi_platform_rhv,multi_platform_sle,multi_platform_slmicro,multi_platform_almalinux
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
{{{ ansible_instantiate_variables("var_selinux_state") }}}

- name: "{{{ rule_title }}} - Check current SELinux state"
  ansible.builtin.command:
    cmd: getenforce
  register: selinux_state
  check_mode: false
  changed_when: false

{{{ ansible_selinux_config_set(parameter="SELINUX", value="{{ var_selinux_state }}", rule_title=rule_title) }}}

- name: "{{{ rule_title }}} - Mark system to relabel SELinux on next boot"
  ansible.builtin.file:
    path: /.autorelabel
    state: touch
    access_time: preserve
    modification_time: preserve
  when: selinux_state.stdout | lower != var_selinux_state
