logstash_plugin: command args as list rather than string (#10573)

* logstash_plugin: command args as list rather than string

* add changelog frag
This commit is contained in:
Alexei Znamensky 2025-08-05 06:02:01 +12:00 committed by GitHub
commit 47ebde3339
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- logstash_plugin - using safer mechanism to run external command (https://github.com/ansible-collections/community.general/issues/10479, https://github.com/ansible-collections/community.general/pull/10520).

View file

@ -104,17 +104,17 @@ def install_plugin(module, plugin_bin, plugin_name, version, proxy_host, proxy_p
cmd_args = [plugin_bin, PACKAGE_STATE_MAP["present"], plugin_name] cmd_args = [plugin_bin, PACKAGE_STATE_MAP["present"], plugin_name]
if version: if version:
cmd_args.append("--version %s" % version) cmd_args.extend(["--version", version])
if proxy_host and proxy_port: if proxy_host and proxy_port:
cmd_args.append("-DproxyHost=%s -DproxyPort=%s" % (proxy_host, proxy_port)) cmd_args.extend(["-DproxyHost=%s" % proxy_host, "-DproxyPort=%s" % proxy_port])
cmd = " ".join(cmd_args) cmd = " ".join(cmd_args)
if module.check_mode: if module.check_mode:
rc, out, err = 0, "check mode", "" rc, out, err = 0, "check mode", ""
else: else:
rc, out, err = module.run_command(cmd) rc, out, err = module.run_command(cmd_args)
if rc != 0: if rc != 0:
reason = parse_error(out) reason = parse_error(out)
@ -131,7 +131,7 @@ def remove_plugin(module, plugin_bin, plugin_name):
if module.check_mode: if module.check_mode:
rc, out, err = 0, "check mode", "" rc, out, err = 0, "check mode", ""
else: else:
rc, out, err = module.run_command(cmd) rc, out, err = module.run_command(cmd_args)
if rc != 0: if rc != 0:
reason = parse_error(out) reason = parse_error(out)