# platform = multi_platform_all
# reboot = false
# strategy = configure
# complexity = low
# disruption = low
- name: Check that the syslog group is defined
  ansible.builtin.getent:
    database: group
    key: syslog
  ignore_errors: true
  when: file_groupowner_var_log_newgroup is undefined
  tags:
  - DISA-STIG-UBTU-22-232125
  - configure_strategy
  - file_groupowner_var_log
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed

- name: Set the file_groupowner_var_log_newgroup variable if syslog found
  ansible.builtin.set_fact:
    file_groupowner_var_log_newgroup: syslog
  when: ansible_facts.getent_group["syslog"] is defined
  tags:
  - DISA-STIG-UBTU-22-232125
  - configure_strategy
  - file_groupowner_var_log
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed

- name: Ensure group owner on /var/log/
  ansible.builtin.file:
    path: /var/log/
    follow: false
    state: directory
    group: '{{ file_groupowner_var_log_newgroup }}'
  tags:
  - DISA-STIG-UBTU-22-232125
  - configure_strategy
  - file_groupowner_var_log
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed
