有没有办法使用 Ansible 注释 cron? 我尝试使用disable
但它不起作用。
剧本:
cron: name="server_agent" disabled=yes
错误信息:
您必须指定"作业"才能安装新的 cron 作业或变量
我的 Ansible 版本是: ansible 2.3.1.0'
有了ansible 2.6
,以下内容就可以工作:
- name: "cron"
hosts: localhost
tasks:
- cron:
name: "test"
job: "/bin/true"
minute: "0"
hour: "9"
state: present
disabled: True
根据文档,这应该从ansible 2.0
开始工作。重要的是,disabled: True
只有在设置state: present
时才有效。Acrontab -l
列出:
#Ansible: test
#0 9 * * * /bin/true