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>
This commit is contained in:
parent
d05b26115b
commit
a788ea0132
2 changed files with 7 additions and 1 deletions
|
@ -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:
|
elif err and rc == 1 and 'Failed to parse bus message' in err:
|
||||||
result['status'] = parse_systemctl_show(to_native(out).split('\n'))
|
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
|
is_systemd = unit in out
|
||||||
|
|
||||||
(rc, out, err) = module.run_command("{systemctl} is-active '{unit}'".format(systemctl=systemctl, unit=unit))
|
(rc, out, err) = module.run_command("{systemctl} is-active '{unit}'".format(systemctl=systemctl, unit=unit))
|
||||||
|
|
Loading…
Reference in a new issue