# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol,multi_platform_almalinux,multi_platform_rhv,multi_platform_ubuntu,multi_platform_sle,multi_platform_slmicro
# reboot = true
# strategy = disable
# complexity = low
# disruption = medium
- name: Gather the package facts
  package_facts:
    manager: auto
  tags:
  - disable_strategy
  - kernel_module_overlayfs_disabled
  - low_complexity
  - low_severity
  - medium_disruption
  - reboot_required

- name: Ensure kernel module 'overlayfs' is disabled
  ansible.builtin.lineinfile:
    create: true
    dest: /etc/modprobe.d/overlayfs.conf
    regexp: install\s+overlayfs
    line: install overlayfs /bin/false
  when: '"linux-base" in ansible_facts.packages'
  tags:
  - disable_strategy
  - kernel_module_overlayfs_disabled
  - low_complexity
  - low_severity
  - medium_disruption
  - reboot_required

- name: Ensure kernel module 'overlayfs' is blacklisted
  ansible.builtin.lineinfile:
    create: true
    dest: /etc/modprobe.d/overlayfs.conf
    regexp: ^blacklist overlayfs$
    line: blacklist overlayfs
  when: '"linux-base" in ansible_facts.packages'
  tags:
  - disable_strategy
  - kernel_module_overlayfs_disabled
  - low_complexity
  - low_severity
  - medium_disruption
  - reboot_required
