mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
return True/False from remove_job_file()
revised fix for https://github.com/ansible/ansible/issues/4795
This commit is contained in:
parent
bcc08564e7
commit
bbfe11fc1e
1 changed files with 3 additions and 5 deletions
|
@ -266,9 +266,10 @@ class CronTab(object):
|
||||||
def remove_job_file(self):
|
def remove_job_file(self):
|
||||||
try:
|
try:
|
||||||
os.unlink(self.cron_file)
|
os.unlink(self.cron_file)
|
||||||
|
return True
|
||||||
except OSError, e:
|
except OSError, e:
|
||||||
# cron file does not exist
|
# cron file does not exist
|
||||||
return
|
return False
|
||||||
except:
|
except:
|
||||||
raise CronTabError("Unexpected error:", sys.exc_info()[0])
|
raise CronTabError("Unexpected error:", sys.exc_info()[0])
|
||||||
|
|
||||||
|
@ -464,10 +465,7 @@ def main():
|
||||||
crontab.write(backup_file)
|
crontab.write(backup_file)
|
||||||
|
|
||||||
if crontab.cron_file and not do_install:
|
if crontab.cron_file and not do_install:
|
||||||
if crontab.remove_job_file():
|
changed = crontab.remove_job_file()
|
||||||
changed = True
|
|
||||||
else:
|
|
||||||
changed = False
|
|
||||||
module.exit_json(changed=changed,cron_file=cron_file,state=state)
|
module.exit_json(changed=changed,cron_file=cron_file,state=state)
|
||||||
|
|
||||||
job = crontab.get_cron_job(minute, hour, day, month, weekday, job, special_time)
|
job = crontab.get_cron_job(minute, hour, day, month, weekday, job, special_time)
|
||||||
|
|
Loading…
Reference in a new issue