The cron module is a similar tool to the at command, but it provides you with more timing options for the execution of the task as the cron module allows you to manage both cron.d and crontab. This module allows the creation and deletion of crontab entries and the creation of environmental variables. As for the playbook example, we will create cron job that makes sure that the shared folder contents have the correct permissions:
- name: setup a cron job
cron:
name: "shared folder permission enforcer"
hour: 0
minute: 0
day: *
job: "chmod -R 777 /media/shared"
state: present
This module can also be handy when working with an environmental variable, such as PATH or HOME, for a crontab entry:
- name: link the cron PATH variable with a new binaries location
cron:
name: PATH
env: yes
value: /usr/local/app/bin