From 47ebde333973c51a064f50b59749dc1671df1251 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Tue, 5 Aug 2025 06:02:01 +1200 Subject: [PATCH] logstash_plugin: command args as list rather than string (#10573) * logstash_plugin: command args as list rather than string * add changelog frag --- changelogs/fragments/10573-logstash-plugin-cmd-list.yml | 2 ++ plugins/modules/logstash_plugin.py | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/10573-logstash-plugin-cmd-list.yml diff --git a/changelogs/fragments/10573-logstash-plugin-cmd-list.yml b/changelogs/fragments/10573-logstash-plugin-cmd-list.yml new file mode 100644 index 0000000000..441c1c49a3 --- /dev/null +++ b/changelogs/fragments/10573-logstash-plugin-cmd-list.yml @@ -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). diff --git a/plugins/modules/logstash_plugin.py b/plugins/modules/logstash_plugin.py index afacf7767f..e6758165f3 100644 --- a/plugins/modules/logstash_plugin.py +++ b/plugins/modules/logstash_plugin.py @@ -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] if version: - cmd_args.append("--version %s" % version) + cmd_args.extend(["--version", version]) 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) if module.check_mode: rc, out, err = 0, "check mode", "" else: - rc, out, err = module.run_command(cmd) + rc, out, err = module.run_command(cmd_args) if rc != 0: reason = parse_error(out) @@ -131,7 +131,7 @@ def remove_plugin(module, plugin_bin, plugin_name): if module.check_mode: rc, out, err = 0, "check mode", "" else: - rc, out, err = module.run_command(cmd) + rc, out, err = module.run_command(cmd_args) if rc != 0: reason = parse_error(out)