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