summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDag Wieers <dag@wieers.com>2019-07-05 15:02:29 +0200
committerToshio Kuratomi <a.badger@gmail.com>2019-10-10 09:15:25 -0700
commitaac216a242ed5ca94200f9637368697fceb931bb (patch)
treef53f958d966dce5d5679df312db5f744a5c1b0ba
parent3a3c6d0f9a04487b037a1650614a3ee8ee4f3333 (diff)
downloadansible-aac216a242ed5ca94200f9637368697fceb931bb.tar.gz
[stable-2.8] Fix regression in cron module (#58751)
This reverts the changes to cron from #28662 This fixes #58493 (cherry picked from commit 61647731e28889cd5ebbf678e9f78aebae7ee812)
-rw-r--r--lib/ansible/modules/system/cron.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/ansible/modules/system/cron.py b/lib/ansible/modules/system/cron.py
index 29c670e2c2..266eae204c 100644
--- a/lib/ansible/modules/system/cron.py
+++ b/lib/ansible/modules/system/cron.py
@@ -581,12 +581,6 @@ def main():
['reboot', 'special_time'],
['insertafter', 'insertbefore'],
],
- required_by=dict(
- cron_file=('user',),
- ),
- required_if=(
- ('state', 'present', ('job',)),
- ),
)
name = module.params['name']
@@ -656,6 +650,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")