From fc65ca200fcfcaa2e7288703cf13a59affc7e18d Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Tue, 2 Dec 2025 09:35:45 -0800 Subject: [PATCH] review request Signed-off-by: Abhijeet Kasurde --- lib/ansible/modules/cron.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/cron.py b/lib/ansible/modules/cron.py index 54ee28b502f..aa49a9f0243 100644 --- a/lib/ansible/modules/cron.py +++ b/lib/ansible/modules/cron.py @@ -313,8 +313,8 @@ class CronTab: elif self.cron_file: try: fileh = open(self.b_cron_file, 'wb') - except FileNotFoundError as ex: - self.module.fail_json(msg=f'Unable to open {self.cron_file} for writing as file does not exists') + except (OSError, FileNotFoundError) as ex: + self.module.fail_json(msg=f'Unable to open {self.cron_file} for writing: {to_native(ex)}') else: try: filed, path = tempfile.mkstemp(prefix='crontab') @@ -671,7 +671,7 @@ def main(): try: (dummy, backup_file) = tempfile.mkstemp(prefix='crontab') except OSError as ex: - module.fail_json(msg=f"Unable to create temporary file for backup: {ex}") + module.fail_json(msg=f"Unable to create temporary file for backup: {to_native(ex)}") crontab.write(backup_file) if env: