systemd - account for templated unit files when searching for service (#72702)

Related to issue #71528 and PR #72337

Co-authored-by: Martin Polden <mpolden@mpolden.no>
pull/72821/head
Sam Doran 4 years ago committed by GitHub
parent d05b26115b
commit a788ea0132
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,4 @@
bugfixes:
- >
systemd - account for templated unit files using ``@`` when searching for
the unit file (https://github.com/ansible/ansible/pull/72347#issuecomment-730626228)

@ -415,7 +415,9 @@ def main():
elif err and rc == 1 and 'Failed to parse bus message' in err:
result['status'] = parse_systemctl_show(to_native(out).split('\n'))
(rc, out, err) = module.run_command("{systemctl} list-unit-files '{unit}*'".format(systemctl=systemctl, unit=unit))
unit, sep, suffix = unit.partition('@')
unit_search = '{unit}{sep}*'.format(unit=unit, sep=sep)
(rc, out, err) = module.run_command("{systemctl} list-unit-files '{unit_search}'".format(systemctl=systemctl, unit_search=unit_search))
is_systemd = unit in out
(rc, out, err) = module.run_command("{systemctl} is-active '{unit}'".format(systemctl=systemctl, unit=unit))

Loading…
Cancel
Save