I have the following task which works in the sense that it comments the desired jobs (job1 to job5) from user's crontab, but what bugs me is that , actually the play appends the jobs and does not replace them.
- name: "Comment cron jobs"
cron:
user: "{{ ansible_env.USER }}"
name: "Comment"
job: "{{ item }}"
state: present
disabled: True
with_items:
- 'job1'
- 'job2'
- 'job3'
- 'job4'
- 'job5'
tags: stop_cronn
This is the result of crontab -l. I want to replace them not to append them .
* * * * * job1
* * * * * job2
* * * * * job3
* * * * * job4
*/5 * * * * job5
#Ansible: None
#* * * * * job1
#Ansible: None
#* * * * * job2
#Ansible: None
#* * * * * job3
#Ansible: None
#* * * * * job4
#Ansible: None
#* * * * * job5
I'm using ansible 2.4.2.0 . Thx