annually or daily or hourly or monthly or reboot or weekly or yearly
特殊时间规范昵称。
state
absent or present,默认present
是否确保作业或环境变量存在或不存在。
user
需要修改crontab的用户。如果不设置,该参数默认使用root。
weekday
默认"*"
作业应该运行的星期几(0-6表示周日-周六,*等)
例子
-name: Ensure a job that runs at 2 and 5 exists. Creates an entry like "0 5,2 * * ls -alh > /dev/null"
cron:name:"check dirs"minute:"0"hour:"5,2"job:"ls -alh > /dev/null"-name:'Ensure an old job is no longer present. Removes any job that is prefixed by "#Ansible: an old job" from the crontab'cron:name:"an old job"state: absent
-name: Creates an entry like "@reboot /some/job.sh"
cron:name:"a job for reboot"special_time: reboot
job:"/some/job.sh"-name: Creates an entry like "PATH=/opt/bin" on top of crontab
cron:name: PATH
env: yes
job: /opt/bin
-name: Creates an entry like "APP_HOME=/srv/app" and insert it after PATH declaration
cron:name: APP_HOME
env: yes
job: /srv/app
insertafter: PATH
-name: Creates a cron file under /etc/cron.d
cron:name: yum autoupdate
weekday:"2"minute:"0"hour:"12"user: root
job:"YUMINTERACTIVE=0 /usr/sbin/yum-autoupdate"cron_file: ansible_yum-autoupdate
-name: Removes a cron file from under /etc/cron.d
cron:name:"yum autoupdate"cron_file: ansible_yum-autoupdate
state: absent
-name: Removes "APP_HOME" environment variable from crontab
cron:name: APP_HOME
env: yes
state: absent