1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

fixed issue with multiline output from systemd

fixes #3868
This commit is contained in:
Brian Coca 2016-06-06 09:39:58 -04:00 committed by Matt Clay
parent eb4813f1ca
commit 03f06ca2e8

View file

@ -514,27 +514,30 @@ class LinuxService(Service):
value_buffer = [] value_buffer = []
status_dict = {} status_dict = {}
for line in out.splitlines(): for line in out.splitlines():
if not key: if '=' in line:
key, value = line.split('=', 1) if not key:
# systemd fields that are shell commands can be multi-line key, value = line.split('=', 1)
# We take a value that begins with a "{" as the start of # systemd fields that are shell commands can be multi-line
# a shell command and a line that ends with "}" as the end of # We take a value that begins with a "{" as the start of
# the command # a shell command and a line that ends with "}" as the end of
if value.lstrip().startswith('{'): # the command
if value.rstrip().endswith('}'): if value.lstrip().startswith('{'):
if value.rstrip().endswith('}'):
status_dict[key] = value
key = None
else:
value_buffer.append(value)
else:
status_dict[key] = value status_dict[key] = value
key = None key = None
else:
if line.rstrip().endswith('}'):
status_dict[key] = '\n'.join(value_buffer)
key = None
else: else:
value_buffer.append(value) value_buffer.append(value)
else:
status_dict[key] = value
key = None
else: else:
if line.rstrip().endswith('}'): value_buffer.append(value)
status_dict[key] = '\n'.join(value_buffer)
key = None
else:
value_buffer.append(value)
return status_dict return status_dict