Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

cron

ansible

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?

like image 424
Nathan Avatar asked Jul 28 '16 11:07

Nathan


1 Answers

Since Ansible 2.0 you have the cronvar command:

# modify /etc/cron.d/sweep_for_rebel_code
- cronvar:
    name: MAILTO
    value: [email protected]
    cron_file: sweep_for_rebel_code

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

like image 50
chiborg Avatar answered Oct 07 '22 14:10

chiborg