2015-05-13 13:33:43 +02:00
---
2015-12-13 22:46:50 +00:00
2016-05-25 19:24:58 +06:00
# es_plugins_reinstall will be set to true if elasticsearch_install_from_repo.changed or elasticsearch_install_from_package.changed
# i.e. we have changed ES version(or we have clean installation of ES), or if no plugins listed. Otherwise it is false and requires explicitly setting.
2016-09-19 13:01:14 +01:00
- set_fact : es_plugins_reinstall=true
2016-09-19 13:18:34 +01:00
when : ((elasticsearch_install_from_repo is defined and elasticsearch_install_from_repo.changed) or (elasticsearch_install_from_package is defined and elasticsearch_install_from_package.changed)) or es_plugins is not defined or es_plugins is none
2016-07-24 17:48:42 +01:00
2016-03-18 19:30:11 +00:00
- set_fact : list_command="list"
2016-07-22 23:44:27 +01:00
2016-03-18 19:30:11 +00:00
- set_fact : list_command="--list"
when : es_version | version_compare('2.0', '<')
2016-01-19 11:50:02 +01:00
2016-11-02 14:29:11 +01:00
- set_fact : es_binary_prefix=""
- set_fact : es_binary_prefix="elasticsearch-"
2016-11-04 15:55:46 +01:00
when : es_version | version_compare('5.0', '>=')
2016-11-02 14:29:11 +01:00
2016-07-24 15:25:32 +01:00
#List currently installed plugins - ignore xpack if > v 2.0
2016-11-02 14:29:11 +01:00
- name : Check installed elasticsearch plugins
2016-11-04 15:56:27 +01:00
shell : "{{es_home}}/bin/{{ es_binary_prefix }}plugin {{list_command}}{% if es_version | version_compare('5.0', '<') %} | sed -n '1!p' | cut -d '-' -f2-{% endif %}{% if es_version | version_compare('2.0', '>') %} | grep -vE '{{supported_xpack_features | join('|')}}|license'{% endif %}"
2016-03-18 19:30:11 +00:00
register : installed_plugins
2016-07-24 17:39:44 +01:00
failed_when : "'ERROR' in installed_plugins.stdout"
2016-03-18 19:30:11 +00:00
changed_when : False
2016-07-22 23:44:27 +01:00
ignore_errors : yes
2016-03-18 19:30:11 +00:00
environment :
2016-07-22 23:44:27 +01:00
CONF_DIR : "{{ conf_dir }}"
ES_INCLUDE : "{{ instance_default_file }}"
2016-01-19 11:50:02 +01:00
2016-11-02 14:29:11 +01:00
# This removes any currently installed plugins (to prevent errors when reinstalling)
2015-05-13 13:33:43 +02:00
- name : Remove elasticsearch plugins
2016-11-02 14:29:11 +01:00
command : "{{es_home}}/bin/{{ es_binary_prefix }}plugin remove {{item}} --silent"
2015-05-13 13:33:43 +02:00
ignore_errors : yes
2016-08-17 16:09:50 +02:00
with_items : "{{ installed_plugins.stdout_lines | default([]) }}"
2016-03-18 19:30:11 +00:00
when : es_plugins_reinstall and installed_plugins.stdout_lines | length > 0 and not 'No plugin detected' in installed_plugins.stdout_lines[0]
2015-12-13 22:46:50 +00:00
notify : restart elasticsearch
2016-11-02 14:29:11 +01:00
register : plugin_removed
2015-12-13 22:46:50 +00:00
environment :
CONF_DIR : "{{ conf_dir }}"
2016-03-18 19:30:11 +00:00
ES_INCLUDE : "{{ instance_default_file }}"
2015-05-13 13:33:43 +02:00
- name : Install elasticsearch plugins
2016-01-27 17:37:07 +01:00
command : >
2016-11-02 14:29:11 +01:00
{{es_home}}/bin/{{ es_binary_prefix }}plugin install {{ item.plugin }}{% if item.version is defined and item.version != '' %}/{{ item.version }}{% endif %} {% if item.proxy_host is defined and item.proxy_host != '' and item.proxy_port is defined and item.proxy_port != ''%} -DproxyHost={{ item.proxy_host }} -DproxyPort={{ item.proxy_port }} {% elif es_proxy_host is defined and es_proxy_host != '' %} -DproxyHost={{ es_proxy_host }} -DproxyPort={{ es_proxy_port }} {% endif %} --silent
2015-12-13 22:46:50 +00:00
register : plugin_installed
2016-03-21 20:16:29 +00:00
failed_when : "'ERROR' in plugin_installed.stdout"
2015-12-13 22:46:50 +00:00
changed_when : plugin_installed.rc == 0
2016-08-17 16:09:50 +02:00
with_items : "{{ es_plugins | default([]) }}"
when : not es_plugins is none and es_plugins_reinstall
2015-12-13 22:46:50 +00:00
notify : restart elasticsearch
environment :
CONF_DIR : "{{ conf_dir }}"
2015-12-22 09:33:45 +00:00
ES_INCLUDE : "{{ instance_default_file }}"
2015-12-13 22:46:50 +00:00
#Set permissions on plugins directory
- name : Set Plugin Directory Permissions
2016-08-30 12:55:45 +01:00
file : state=directory path={{ es_home }}/plugins owner={{ es_user }} group={{ es_group }} recurse=yes