---
- name: Install cron-related packages
  apt:
    name:
      - cron
      - tmpreaper

- name: Generate Cron Template
  template:
    src: azuracast_cron.j2
    dest: "{{ tmp_base }}/azuracast_cron"
    force: true
    mode: 0644

- name: Install Cron file
  command: >-
    crontab -u azuracast {{ tmp_base }}/azuracast_cron

- name: Clean up temp Cron file
  file:
    path: "{{ tmp_base }}/azuracast_cron"
    state: absent

- name: Install Cron Supervisord conf
  template:
    src: supervisor.conf.j2
    dest: /etc/supervisor/conf.d/cron.conf
    force: true
    mode: 0644

- name: Disable Cron service
  service:
    name: "cron"
    enabled: false
    state: stopped
  ignore_errors: true
