# platform = multi_platform_all
# reboot = false
# strategy = configure
# complexity = low
# disruption = low
- name: Check that the crontab group is defined
  ansible.builtin.getent:
    database: group
    key: crontab
  ignore_errors: yes
  when: file_groupowner_cron_allow_newgroup is undefined

- name: Set the file_groupowner_cron_allow_newgroup variable if crontab found
  ansible.builtin.set_fact:
    file_groupowner_cron_allow_newgroup: "crontab"
  when: ansible_facts.getent_group["crontab"] is defined

- name: Test for existence /etc/cron.allow
  ansible.builtin.stat:
    path: "/etc/cron.allow"
  register: file_exists

- name: Ensure group owner on /etc/cron.allow
  ansible.builtin.file:
    path: "/etc/cron.allow"
    follow: false
    group: "{{ file_groupowner_cron_allow_newgroup }}"
  when: file_exists.stat is defined and file_exists.stat.exists


