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")