From 03f06ca2e8e59c6e3d533e1caea38f5f0c00d92b Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Mon, 6 Jun 2016 09:39:58 -0400 Subject: [PATCH] fixed issue with multiline output from systemd fixes #3868 --- lib/ansible/modules/system/service.py | 35 +++++++++++++++------------ 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/lib/ansible/modules/system/service.py b/lib/ansible/modules/system/service.py index b0e39993a9..2e89fb8739 100644 --- a/lib/ansible/modules/system/service.py +++ b/lib/ansible/modules/system/service.py @@ -514,27 +514,30 @@ class LinuxService(Service): value_buffer = [] status_dict = {} for line in out.splitlines(): - if not key: - key, value = line.split('=', 1) - # systemd fields that are shell commands can be multi-line - # We take a value that begins with a "{" as the start of - # a shell command and a line that ends with "}" as the end of - # the command - if value.lstrip().startswith('{'): - if value.rstrip().endswith('}'): + if '=' in line: + if not key: + key, value = line.split('=', 1) + # systemd fields that are shell commands can be multi-line + # We take a value that begins with a "{" as the start of + # a shell command and a line that ends with "}" as the end of + # the command + if value.lstrip().startswith('{'): + if value.rstrip().endswith('}'): + status_dict[key] = value + key = None + else: + value_buffer.append(value) + else: status_dict[key] = value key = None + else: + if line.rstrip().endswith('}'): + status_dict[key] = '\n'.join(value_buffer) + key = None else: value_buffer.append(value) - else: - status_dict[key] = value - key = None else: - if line.rstrip().endswith('}'): - status_dict[key] = '\n'.join(value_buffer) - key = None - else: - value_buffer.append(value) + value_buffer.append(value) return status_dict