Cron File Management

I’m building a cron server that will basically just serve as a central server to run cron jobs from. I’m having trouble planning/implementing the cron functionality in ansible. There will likely be many jobs under many categories, so I would rather not make a play for each job, especially as they could change often. I was thinking about making a template for a cron file and using the template module with some variables to make categorized cron files under /etc/cron.d/. I can’t seem to figure out how the variables will work without needing to make separate templates for each category just to get the variables as a whole object. Example:

./vars/main.yml

“If I just change the template to {{item}} to output whatever is input, the play loops over each job in the variable and the end file only contains the last job.”

If you are writing to different cron.d files, the template that you have there in cron.j2 should be fine.

Also take a look at the using “cron” module which should simplify some things.