# Crons on a collection of servers

**URL:** <https://forum.ansible.com/t/crons-on-a-collection-of-servers/23914>\
**Category:** Ansible Project\
**Created:** [March 8, 2017, 4:27pm UTC](https://forum.ansible.com/t/crons-on-a-collection-of-servers/23914 "2017-03-08T16:27:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ed\_Greenberg](https://avatars.discourse-cdn.com/v4/letter/e/7ab992/32.png) [@Ed\_Greenberg](https://forum.ansible.com/u/Ed_Greenberg)\
**Post date:** [March 8, 2017, 4:27pm UTC](https://forum.ansible.com/t/crons-on-a-collection-of-servers/23914/1 "2017-03-08T16:27:24Z")

</div>

We have a collection of load balanced web servers, and we have cron jobs spread across the server base.

I would like to manage these cron jobs in Ansible.

The current state is to have all the cron jobs on all the servers, disabled, and then to selectively enable the ones that need to run on each server.

On my test server, I rolled out all the cron jobs as state=present disabled=true and got all the cron jobs, properly commented out.

I can do a play as follows:

- name: cron Update Webmin  
cron:  
user: root  
state: present  
name: “Update Webmin”  
minute: “10”  
hour: “10”  
day: “_"  
month: "_”  
weekday: “2”  
job: “/etc/webmin/package-updates/update.pl”  
when: ansible\_hostname == ‘web-node-1’

But when I go into the playbook and change web-host-1 to web-host-2, that won’t remove the job from web1.

So my current thought is:

- name: cron Update Webmin  
cron:  
user: root  
state: present  
disabled: true  
name: “Update Webmin”  
minute: “10”  
hour: “10”  
day: “_"  
month: "_”  
weekday: “2”  
job: “/etc/webmin/package-updates/update.pl”

- name: cron Update Webmin  
cron:  
user: root  
state: present  
name: “Update Webmin”  
minute: “10”  
hour: “10”  
day: “_"  
month: "_”  
weekday: “2”  
job: “/etc/webmin/package-updates/update.pl”  
when: ansible\_hostname == ‘web-node-1’

This should roll all the jobs to all the servers, then enable them only where needed.

So, for a reality check, does this seem the best method?

Thanks,

Ed G

---

<div class="post-metadata">

**Author:** ![Dick\_Davies](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Dick\_Davies](https://forum.ansible.com/u/Dick_Davies)\
**Post date:** [March 8, 2017, 4:32pm UTC](https://forum.ansible.com/t/crons-on-a-collection-of-servers/23914/2 "2017-03-08T16:32:24Z")

</div>

Why don't you just set disabled: as a var, and then set that either  
true or false on each server/group  
as needed?
