Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed cron library so backups are python2.4 compatible #1318

Merged
merged 1 commit into from
Oct 12, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 5 additions & 6 deletions library/cron
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,11 @@ def main():
(rc, out, err) = get_jobs_file(user,tmpfile.name)
if rc != 0 and rc != 1: # 1 can mean that there are no jobs.
module.fail_json(msg=err)
backupfile = tempfile.NamedTemporaryFile(prefix='crontab',delete=False)
(rc, out, err) = get_jobs_file(user,backupfile.name)
(handle,backupfile) = tempfile.mkstemp(prefix='crontab')
(rc, out, err) = get_jobs_file(user,backupfile)
if rc != 0 and rc != 1:
module.fail_json(msg=err)
old_job = find_job(name,backupfile.name)
old_job = find_job(name,backupfile)
if do_install:
if len(old_job) == 0:
(rc, out, err) = add_job(name,job,tmpfile.name)
Expand All @@ -271,7 +271,7 @@ def main():
module.fail_json(msg=err)
if changed:
if backup:
module.backup_local(backupfile.name)
module.backup_local(backupfile)
(rc, out, err) = install_jobs(user,tmpfile.name)
if (rc != 0):
module.fail_json(msg=err)
Expand All @@ -280,11 +280,10 @@ def main():
for j in get_jobs(tmpfile.name):
jobnames.append(j[0])
tmpfile.close()
backupfile.close()
if not backup:
module.exit_json(changed=changed,jobs=jobnames)
else:
module.exit_json(changed=changed,jobs=jobnames,backup=backupfile.name)
module.exit_json(changed=changed,jobs=jobnames,backup=backupfile)

# include magic from lib/ansible/module_common.py
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
Expand Down