Question:
I’m using Ansible to create a cron.d file using the cron_file parameter.
But how can I add a MAILTO to the file?
It seems the env=true is only for crontab, not cron.d files. Am I wrong?
Answer:
Since Ansible 2.0 you have the cronvar
command:
1 2 3 4 5 6 |
# modify /etc/cron.d/sweep_for_rebel_code - cronvar: name: MAILTO value: vader@evilempire.com cron_file: sweep_for_rebel_code |
See the official documentation at https://docs.ansible.com/ansible/latest/modules/cronvar_module.html