---
- name: cronie | Install cronie package
  community.general.apk:
    name: cronie
    state: present

- name: cronie | Allow access to crontabs for only root and {{ username }}
  copy:
    content: |
      {{ username }}
    dest: /etc/cron.allow
    owner: root
    group: root
    mode: '644'

# btrbk runs btrfs command directly (without specifying /sbin prefix),
# hence we need to inherit PATH here. Also log to syslog
# (the default PATH is /usr/local/bin:/bin:/usr/bin)
- name: cronie | Configure command options for cronie service
  copy:
    content: |
      CRON_OPTS="-s -P"
    dest: /etc/conf.d/cronie
    owner: root
    group: root
    mode: '644'

- name: cronie | Start cronie service in runlevel default
  service:
    name: cronie
    runlevel: default
    state: started
    enabled: true
