# platform = multi_platform_all
# reboot = false
# strategy = configure
# complexity = low
# disruption = low
- name: Gather the package facts
  package_facts:
    manager: auto
  tags:
  - DISA-STIG-UBTU-22-653065
  - configure_strategy
  - file_permissions_etc_audit_rules
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed

- name: Test for existence /etc/audit/audit.rules
  ansible.builtin.stat:
    path: /etc/audit/audit.rules
  register: file_exists
  when: '"linux-base" in ansible_facts.packages'
  tags:
  - DISA-STIG-UBTU-22-653065
  - configure_strategy
  - file_permissions_etc_audit_rules
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed

- name: Ensure permission u-xs,g-xws,o-xwrt on /etc/audit/audit.rules
  ansible.builtin.file:
    path: /etc/audit/audit.rules
    mode: u-xs,g-xws,o-xwrt
  when:
  - '"linux-base" in ansible_facts.packages'
  - file_exists.stat is defined and file_exists.stat.exists
  tags:
  - DISA-STIG-UBTU-22-653065
  - configure_strategy
  - file_permissions_etc_audit_rules
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed
