warn on systemd globs (#56645)

* warn on systemd globs
* added note to docs

  fixes 55476
This commit is contained in:
Brian Coca 2019-05-24 10:52:36 -04:00 committed by GitHub
parent 9a563f8947
commit f96529d20e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- warn user when attempting to use service with globs in systemd module.

View file

@ -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),
and all except 'daemon_reload' (and 'daemon_reexec' since 2.8) also require 'name'.
- Before 2.4 you always required 'name'.
- Globs are not supported in name, i.e ``postgres*.service``.
requirements:
- A system managed by systemd.
'''
@ -339,6 +340,11 @@ def main():
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)
if os.getenv('XDG_RUNTIME_DIR') is None:
@ -364,7 +370,6 @@ def main():
if module.params['force']:
systemctl += " --force"
unit = module.params['name']
rc = 0
out = err = ''
result = dict(