Added warning for cron jobs containing line breaks (#19184)

Fixes ansible/ansible-modules-core#4312, moved from ansible/ansible-modules-core#4488
This commit is contained in:
Evan Kaufman 2017-07-26 23:19:36 -07:00 committed by ansibot
parent d2f34754b2
commit 589e8fd6bc

View file

@ -69,6 +69,7 @@ options:
job: job:
description: description:
- The command to execute or, if env is set, the value of environment variable. - 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 if state=present.
required: false required: false
aliases: ['value'] aliases: ['value']
@ -718,6 +719,11 @@ def main():
changed = True changed = True
else: else:
if do_install: 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) job = crontab.get_cron_job(minute, hour, day, month, weekday, job, special_time, disabled)
old_job = crontab.find_job(name, job) old_job = crontab.find_job(name, job)