# platform = multi_platform_all
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low

- name: "Put contents into /etc/audit/rules.d/43-module-load.rules according to policy"
  ansible.builtin.copy:
    dest: "/etc/audit/rules.d/43-module-load.rules"
    content: |+
        ## These rules watch for kernel module insertion. By monitoring
        ## the syscall, we do not need any watches on programs.
        -a always,exit -F arch=b32 -S init_module,finit_module -F key=module-load
        -a always,exit -F arch=b64 -S init_module,finit_module -F key=module-load
        -a always,exit -F arch=b32 -S delete_module -F key=module-unload
        -a always,exit -F arch=b64 -S delete_module -F key=module-unload
    force: yes

- name: Configure auditing of loading and unloading of kernel modules - Remove any permissions from group and other
  ansible.builtin.file:
    path: /etc/audit/rules.d/43-module-load.rules
    mode: g-rwx,o-rwx
    state: touch