# Manage crontab

This role is very simple is use the same parameters of module cron (https://docs.ansible.com/ansible/latest/modules/cron_module.html).

<!-- TOC -->
* [Manage crontab](#manage-crontab)
  * [Examples](#examples)
  * [Silence `/etc/cron.d/` crons](#silence-etccrond-crons)
<!-- TOC -->

## Examples

Cron restart apache2 every 4 hours:
```yaml
cron_tasks:
  - name: "Restart apache2 "
    minute: "0"
    hour: "*/4"
    job: "systemctl restart apache2.service"
```

Environnement variable:
```yaml
cron_tasks:
  - name: MAILTO
    env: yes
    value: ""
```

## Silence `/etc/cron.d/` crons

This is an edge case, crons souldn't be managed this way, but you can silence mails from crons inside `/etc/cron.d/*` files by adding `MAILTO=""` for root, e.g. with:
```yaml
crontab_silence_files: [sentry, belgique_demo]
```
N.B.: only existing files are updated.
