warn on systemd globs (#56645)
* warn on systemd globs * added note to docs fixes 55476
This commit is contained in:
parent
9a563f8947
commit
f96529d20e
2 changed files with 8 additions and 1 deletions
2
changelogs/fragments/warn_systemd_glob.yml
Normal file
2
changelogs/fragments/warn_systemd_glob.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- warn user when attempting to use service with globs in systemd module.
|
|
@ -83,6 +83,7 @@ notes:
|
||||||
- Since 2.4, one of the following options is required 'state', 'enabled', 'masked', 'daemon_reload', ('daemon_reexec' since 2.8),
|
- Since 2.4, one of the following options is required 'state', 'enabled', 'masked', 'daemon_reload', ('daemon_reexec' since 2.8),
|
||||||
and all except 'daemon_reload' (and 'daemon_reexec' since 2.8) also require 'name'.
|
and all except 'daemon_reload' (and 'daemon_reexec' since 2.8) also require 'name'.
|
||||||
- Before 2.4 you always required 'name'.
|
- Before 2.4 you always required 'name'.
|
||||||
|
- Globs are not supported in name, i.e ``postgres*.service``.
|
||||||
requirements:
|
requirements:
|
||||||
- A system managed by systemd.
|
- A system managed by systemd.
|
||||||
'''
|
'''
|
||||||
|
@ -339,6 +340,11 @@ def main():
|
||||||
mutually_exclusive=[['scope', 'user']],
|
mutually_exclusive=[['scope', 'user']],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
unit = module.params['name']
|
||||||
|
for globpattern in (r"*", r"?", r"["):
|
||||||
|
if globpattern in unit:
|
||||||
|
module.fail_json(msg="This module does not currently support using glob patterns, found '%s' in service name: %s" % (globpattern, unit))
|
||||||
|
|
||||||
systemctl = module.get_bin_path('systemctl', True)
|
systemctl = module.get_bin_path('systemctl', True)
|
||||||
|
|
||||||
if os.getenv('XDG_RUNTIME_DIR') is None:
|
if os.getenv('XDG_RUNTIME_DIR') is None:
|
||||||
|
@ -364,7 +370,6 @@ def main():
|
||||||
if module.params['force']:
|
if module.params['force']:
|
||||||
systemctl += " --force"
|
systemctl += " --force"
|
||||||
|
|
||||||
unit = module.params['name']
|
|
||||||
rc = 0
|
rc = 0
|
||||||
out = err = ''
|
out = err = ''
|
||||||
result = dict(
|
result = dict(
|
||||||
|
|
Loading…
Reference in a new issue