diff --git a/lib/ansible/modules/system/cron.py b/lib/ansible/modules/system/cron.py index 2d3ea55cf1a..692d56c8332 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