How to add MAILTO to a cron.d cron_file in Ansible?

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:

See the official documentation at https://docs.ansible.com/ansible/latest/modules/cronvar_module.html

Leave a Reply