ansible/ansible — pull request #3196 by lalinsky (2013-06-13 16:58:36+00:00)
Title: Add a new crontab module

The module can be used to maintain the whole crontab for a particular user, rather than maintaining individual cron jobs with the cron module. It can use a local file or Jinja2 template for the crontab's content.

I couldn't use `/etc/cron.d` with a specific file because that's not supported by the FreeBSD cron and I also needed to maintain environment variables in a crontab, like `MAILTO` and `PATH`, so I wrote this module. It works like the `copy` or `template` modules, but instead of creating a file, it saves the content of the local file/template to a user's crontab.

It supports the check mode and can display diffs. I initially had this implemented a simple module that used syntax like this:

crontab: user=xxx content="{{ lookup('template', 'xxx.j2') }}"

Eventually I decided that I really want diff support and the `template=xxx.j2` syntax also looks nicer, so I implemented the action plugin for it as well.

I'm not sure if this is something that should be merged to the main module library in ansible, but it works great for my purposes.