From 61647731e28889cd5ebbf678e9f78aebae7ee812 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Fri, 5 Jul 2019 15:02:29 +0200 Subject: [PATCH] Fix regression in cron module (#58751) This reverts the changes to cron from #28662 This fixes #58493 --- lib/ansible/modules/system/cron.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/ansible/modules/system/cron.py b/lib/ansible/modules/system/cron.py index b9279455b7c..8d8e764449c 100644 --- a/lib/ansible/modules/system/cron.py +++ b/lib/ansible/modules/system/cron.py @@ -582,12 +582,6 @@ def main(): ['reboot', 'special_time'], ['insertafter', 'insertbefore'], ], - required_by=dict( - cron_file=('user',), - ), - required_if=( - ('state', 'present', ('job',)), - ), ) name = module.params['name'] @@ -657,6 +651,13 @@ def main(): if (special_time or reboot) and get_platform() == 'SunOS': module.fail_json(msg="Solaris does not support special_time=... or @reboot") + if cron_file and do_install: + if not user: + module.fail_json(msg="To use cron_file=... parameter you must specify user=... as well") + + if job is None and do_install: + module.fail_json(msg="You must specify 'job' to install a new cron job or variable") + if (insertafter or insertbefore) and not env and do_install: module.fail_json(msg="Insertafter and insertbefore parameters are valid only with env=yes")