mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
parent
eb4813f1ca
commit
03f06ca2e8
1 changed files with 19 additions and 16 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue