From 5df2dadcdba4c24a68b7a24c5ebbecae3f82fa98 Mon Sep 17 00:00:00 2001 From: Seth Vidal Date: Tue, 16 Apr 2013 15:07:59 -0400 Subject: [PATCH] clean up how it puts the files in place - in f18 /tmp is tmpfs which means ln and os.rename() won't work across fs. --- library/cron | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/library/cron b/library/cron index ebd3b6cb07..73eca78903 100644 --- a/library/cron +++ b/library/cron @@ -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()