---

- name: Get list of SELinux modules loaded
  command: semodule -l
  changed_when: False
  register: selinux_modules
  check_mode: no

- name: Compile SELinux rules
  include_tasks:
    file: keepalived_selinux_compile.yml
  when:
    - selinux_policy_name not in selinux_modules.stdout
  loop: "{{ keepalived_selinux_compile_rules }}"
  loop_control:
    loop_var: selinux_policy_name
