Ansible Ansbile Cron对Cron_TZ的支持

Ansible Ansbile Cron对Cron_TZ的支持,ansible,ansible-2.x,Ansible,Ansible 2.x,我似乎找不到对crontab的CRON_TZ设置的支持。如何配置ansible以针对特定时区运行cron作业 这就是我想要的crontab文件的样子。此cron配置当前正在CentOS 7机箱上运行 /etc/crontab: # Default Timezone 30 9 * * * bobr /home/bobr/crontest.sh LOCAL "`date -R`" CRON_TZ=Canada/Eastern 30 11 * * * bobr /home/bobr/crontest

我似乎找不到对crontab的CRON_TZ设置的支持。如何配置ansible以针对特定时区运行cron作业

这就是我想要的crontab文件的样子。此cron配置当前正在CentOS 7机箱上运行

/etc/crontab:

# Default Timezone
30 9 * * * bobr /home/bobr/crontest.sh LOCAL "`date -R`"

CRON_TZ=Canada/Eastern
30 11 * * * bobr /home/bobr/crontest.sh Eastern "`date -R`"
45 11 * * * bobr/home/bobr/crontest.sh Eastern "`date -R`"

CRON_TZ=Canada/Pacific
30 8 * * * bobr/home/bobr/crontest.sh Pacific "`date -R`"
44 8 * * * bobr/home/bobr/crontest.sh Pacific "`date -R`"
作为参考,crontest.sh只发送一封包含2个参数的电子邮件:

#!/bin/bash

echo "this is the cron test. $1 $2" | mail -s "Cron Test" bobr@example.com


未找到ansible模块中设置的时区的任何属性。。也许你可以试试别的办法。。使用shell

- name: configure cron using shell
  shell:  crontab cron.conf
而conf文件是

cat cron.conf
# Default Timezone
30 9 * * * bobr /home/bobr/crontest.sh LOCAL "`date -R`"

CRON_TZ=Canada/Eastern
30 11 * * * bobr /home/bobr/crontest.sh Eastern "`date -R`"
45 11 * * * bobr/home/bobr/crontest.sh Eastern "`date -R`"

CRON_TZ=Canada/Pacific
30 8 * * * bobr/home/bobr/crontest.sh Pacific "`date -R`"
44 8 * * * bobr/home/bobr/crontest.sh Pacific "`date -R`"

非常感谢。我考虑过这个问题,但正试图找到一个更合适的方法来解决这个问题。我可能只是做了一个模板。我在这里提交了一个功能请求: