mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add the possiblity to force a plugin installation (#41688)
This commit is contained in:
parent
42c2fd72ae
commit
26abdbf0fd
2 changed files with 22 additions and 2 deletions
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
minor_changes:
|
||||||
|
- elasticsearch_plugin - Add the possibility to use the elasticsearch_plugin installation batch mode
|
||||||
|
to install plugins with advanced privileges without user interaction.
|
|
@ -43,6 +43,11 @@ options:
|
||||||
- "Timeout setting: 30s, 1m, 1h..."
|
- "Timeout setting: 30s, 1m, 1h..."
|
||||||
- Only valid for Elasticsearch < 5.0. This option is ignored for Elasticsearch > 5.0.
|
- Only valid for Elasticsearch < 5.0. This option is ignored for Elasticsearch > 5.0.
|
||||||
default: 1m
|
default: 1m
|
||||||
|
force:
|
||||||
|
description:
|
||||||
|
- "Force batch mode when installing plugins. This is only necessary if a plugin requires additional permissions and console detection fails."
|
||||||
|
default: False
|
||||||
|
version_added: "2.7"
|
||||||
plugin_bin:
|
plugin_bin:
|
||||||
description:
|
description:
|
||||||
- Location of the plugin binary. If this file is not found, the default plugin binaries will be used.
|
- Location of the plugin binary. If this file is not found, the default plugin binaries will be used.
|
||||||
|
@ -85,6 +90,12 @@ EXAMPLES = '''
|
||||||
- elasticsearch_plugin:
|
- elasticsearch_plugin:
|
||||||
name: analysis-icu
|
name: analysis-icu
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
|
# Install the ingest-geoip plugin with a forced installation
|
||||||
|
- elasticsearch_plugin:
|
||||||
|
name: ingest-geoip
|
||||||
|
state: present
|
||||||
|
force: yes
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -134,7 +145,7 @@ def parse_error(string):
|
||||||
return string
|
return string
|
||||||
|
|
||||||
|
|
||||||
def install_plugin(module, plugin_bin, plugin_name, version, url, proxy_host, proxy_port, timeout):
|
def install_plugin(module, plugin_bin, plugin_name, version, url, proxy_host, proxy_port, timeout, force):
|
||||||
cmd_args = [plugin_bin, PACKAGE_STATE_MAP["present"], plugin_name]
|
cmd_args = [plugin_bin, PACKAGE_STATE_MAP["present"], plugin_name]
|
||||||
|
|
||||||
# Timeout and version are only valid for plugin, not elasticsearch-plugin
|
# Timeout and version are only valid for plugin, not elasticsearch-plugin
|
||||||
|
@ -152,6 +163,9 @@ def install_plugin(module, plugin_bin, plugin_name, version, url, proxy_host, pr
|
||||||
if url:
|
if url:
|
||||||
cmd_args.append("--url %s" % url)
|
cmd_args.append("--url %s" % url)
|
||||||
|
|
||||||
|
if force:
|
||||||
|
cmd_args.append("--batch")
|
||||||
|
|
||||||
cmd = " ".join(cmd_args)
|
cmd = " ".join(cmd_args)
|
||||||
|
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
|
@ -221,6 +235,7 @@ def main():
|
||||||
state=dict(default="present", choices=PACKAGE_STATE_MAP.keys()),
|
state=dict(default="present", choices=PACKAGE_STATE_MAP.keys()),
|
||||||
url=dict(default=None),
|
url=dict(default=None),
|
||||||
timeout=dict(default="1m"),
|
timeout=dict(default="1m"),
|
||||||
|
force=dict(default=False),
|
||||||
plugin_bin=dict(type="path"),
|
plugin_bin=dict(type="path"),
|
||||||
plugin_dir=dict(default="/usr/share/elasticsearch/plugins/", type="path"),
|
plugin_dir=dict(default="/usr/share/elasticsearch/plugins/", type="path"),
|
||||||
proxy_host=dict(default=None),
|
proxy_host=dict(default=None),
|
||||||
|
@ -234,6 +249,7 @@ def main():
|
||||||
state = module.params["state"]
|
state = module.params["state"]
|
||||||
url = module.params["url"]
|
url = module.params["url"]
|
||||||
timeout = module.params["timeout"]
|
timeout = module.params["timeout"]
|
||||||
|
force = module.params["force"]
|
||||||
plugin_bin = module.params["plugin_bin"]
|
plugin_bin = module.params["plugin_bin"]
|
||||||
plugin_dir = module.params["plugin_dir"]
|
plugin_dir = module.params["plugin_dir"]
|
||||||
proxy_host = module.params["proxy_host"]
|
proxy_host = module.params["proxy_host"]
|
||||||
|
@ -250,7 +266,7 @@ def main():
|
||||||
module.exit_json(changed=False, name=name, state=state)
|
module.exit_json(changed=False, name=name, state=state)
|
||||||
|
|
||||||
if state == "present":
|
if state == "present":
|
||||||
changed, cmd, out, err = install_plugin(module, plugin_bin, name, version, url, proxy_host, proxy_port, timeout)
|
changed, cmd, out, err = install_plugin(module, plugin_bin, name, version, url, proxy_host, proxy_port, timeout, force)
|
||||||
|
|
||||||
elif state == "absent":
|
elif state == "absent":
|
||||||
changed, cmd, out, err = remove_plugin(module, plugin_bin, name)
|
changed, cmd, out, err = remove_plugin(module, plugin_bin, name)
|
||||||
|
|
Loading…
Reference in a new issue