|
|
|
@ -132,6 +132,7 @@ updates: Mike Grozak
|
|
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
import tempfile
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
def get_jobs_file(module, user, tmpfile, cron_file):
|
|
|
|
|
if cron_file:
|
|
|
|
@ -143,11 +144,19 @@ def get_jobs_file(module, user, tmpfile, cron_file):
|
|
|
|
|
|
|
|
|
|
def install_jobs(module, user, tmpfile, cron_file):
|
|
|
|
|
if cron_file:
|
|
|
|
|
cmd = "ln -f %s /etc/cron.d/%s" % (tmpfile, cron_file)
|
|
|
|
|
cron_file = '/etc/cron.d/%s' % cron_file
|
|
|
|
|
try:
|
|
|
|
|
module.atomic_replace(tmpfile, cron_file)
|
|
|
|
|
except (OSError, IOError), e:
|
|
|
|
|
return (1, "", str(e))
|
|
|
|
|
except:
|
|
|
|
|
return (1, "", str(e))
|
|
|
|
|
else:
|
|
|
|
|
return (0, "", "")
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
cmd = "crontab %s %s" % (user, tmpfile)
|
|
|
|
|
|
|
|
|
|
return module.run_command(cmd)
|
|
|
|
|
return module.run_command(cmd)
|
|
|
|
|
|
|
|
|
|
def get_jobs(tmpfile):
|
|
|
|
|
lines = open(tmpfile).read().splitlines()
|
|
|
|
|