From ce584571e810c19f6d1134ae95c1b8eb69663ed3 Mon Sep 17 00:00:00 2001 From: Evan Kaufman Date: Fri, 26 May 2017 07:16:15 -0700 Subject: [PATCH] Fixed backup file behavior in check mode (#24899) Fixes ansible/ansible#21523 --- lib/ansible/modules/system/cron.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/system/cron.py b/lib/ansible/modules/system/cron.py index 2d3ea55cf1..692d56c833 100644 --- a/lib/ansible/modules/system/cron.py +++ b/lib/ansible/modules/system/cron.py @@ -752,12 +752,11 @@ def main(): res_args['diff'] = diff # retain the backup only if crontab or cron file have changed - if backup: + if backup and not module.check_mode: if changed: res_args['backup_file'] = backup_file else: - if not module.check_mode: - os.unlink(backup_file) + os.unlink(backup_file) if cron_file: res_args['cron_file'] = cron_file