ansible支持评论cron工作

问题描述 投票:0回答:1

有没有办法用ansbile评论一个cron?我试图使用disable但不工作。

剧本:cron: name="server_agent" disabled=yes

Error message: You must specify 'job' to install a new cron job or variable

ansible version: ansible 2.3.1.0

cron ansible
1个回答
1
投票

使用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时才有效。一个crontab -l列表:

#Ansible: test
#0 9 * * * /bin/true
© www.soinside.com 2019 - 2024. All rights reserved.