From 589e8fd6bc5a488512269470d836149dc3c08988 Mon Sep 17 00:00:00 2001 From: Evan Kaufman Date: Wed, 26 Jul 2017 23:19:36 -0700 Subject: [PATCH] Added warning for cron jobs containing line breaks (#19184) Fixes ansible/ansible-modules-core#4312, moved from ansible/ansible-modules-core#4488 --- lib/ansible/modules/system/cron.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ansible/modules/system/cron.py b/lib/ansible/modules/system/cron.py index 8e1a9a25dd..90d5c4d6aa 100644 --- a/lib/ansible/modules/system/cron.py +++ b/lib/ansible/modules/system/cron.py @@ -69,6 +69,7 @@ options: job: description: - The command to execute or, if env is set, the value of environment variable. + The command should not contain line breaks. Required if state=present. required: false aliases: ['value'] @@ -718,6 +719,11 @@ def main(): changed = True else: if do_install: + for char in ['\r', '\n']: + if char in job.strip('\r\n'): + warnings.append('Job should not contain line breaks') + break + job = crontab.get_cron_job(minute, hour, day, month, weekday, job, special_time, disabled) old_job = crontab.find_job(name, job)