From f64990df02c3d5411648d40fd5399ed086ec79b3 Mon Sep 17 00:00:00 2001 From: Evan Kaufman Date: Thu, 4 Aug 2016 14:00:04 -0700 Subject: [PATCH] Rendering of crontab should reflect actual newline termination, in diff mode --- lib/ansible/modules/system/cron.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/system/cron.py b/lib/ansible/modules/system/cron.py index 7c7a397eb7..2b4b708bc2 100644 --- a/lib/ansible/modules/system/cron.py +++ b/lib/ansible/modules/system/cron.py @@ -460,7 +460,7 @@ class CronTab(object): self.lines = newlines - def render(self): + def render(self, diff=None): """ Render this crontab as it would be in the crontab. """ @@ -469,7 +469,7 @@ class CronTab(object): crons.append(cron) result = '\n'.join(crons) - if result: + if result and not diff: result = result.rstrip('\r\n') + '\n' return result @@ -586,7 +586,7 @@ def main(): if module._diff: diff = dict() - diff['before'] = crontab.render() + diff['before'] = crontab.render(diff=True) if crontab.cron_file: diff['before_header'] = crontab.cron_file else: