Skip to content

Commit 47ebde3

Browse files
authored
logstash_plugin: command args as list rather than string (#10573)
* logstash_plugin: command args as list rather than string * add changelog frag
1 parent 85f6a07 commit 47ebde3

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
minor_changes:
2+
- 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).

plugins/modules/logstash_plugin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,17 @@ def install_plugin(module, plugin_bin, plugin_name, version, proxy_host, proxy_p
104104
cmd_args = [plugin_bin, PACKAGE_STATE_MAP["present"], plugin_name]
105105

106106
if version:
107-
cmd_args.append("--version %s" % version)
107+
cmd_args.extend(["--version", version])
108108

109109
if proxy_host and proxy_port:
110-
cmd_args.append("-DproxyHost=%s -DproxyPort=%s" % (proxy_host, proxy_port))
110+
cmd_args.extend(["-DproxyHost=%s" % proxy_host, "-DproxyPort=%s" % proxy_port])
111111

112112
cmd = " ".join(cmd_args)
113113

114114
if module.check_mode:
115115
rc, out, err = 0, "check mode", ""
116116
else:
117-
rc, out, err = module.run_command(cmd)
117+
rc, out, err = module.run_command(cmd_args)
118118

119119
if rc != 0:
120120
reason = parse_error(out)
@@ -131,7 +131,7 @@ def remove_plugin(module, plugin_bin, plugin_name):
131131
if module.check_mode:
132132
rc, out, err = 0, "check mode", ""
133133
else:
134-
rc, out, err = module.run_command(cmd)
134+
rc, out, err = module.run_command(cmd_args)
135135

136136
if rc != 0:
137137
reason = parse_error(out)

0 commit comments

Comments
 (0)