2015-05-13 13:33:43 +02:00
---
2015-12-13 22:46:50 +00:00
2016-03-18 19:30:11 +00:00
#es_plugins_reinstall will be set to true if elasticsearch_install.changed i.e. we have changed ES version, or if no plugins listed. Otherwise it is false and requires explicitly setting.
2016-01-19 11:50:02 +01:00
- set_fact : es_plugins_reinstall=true
2016-03-18 19:30:11 +00:00
when : elasticsearch_install.changed or es_plugins is not defined or es_plugins is none
2016-01-19 11:50:02 +01:00
2016-03-18 19:30:11 +00:00
- set_fact : list_command="list"
2016-01-19 11:50:02 +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-03-18 19:30:11 +00:00
#List currently installed plugins
- shell : "{{es_home}}/bin/plugin {{list_command}} | sed -n '1!p' | cut -d '-' -f2-"
register : installed_plugins
changed_when : False
environment :
CONF_DIR : "{{ conf_dir }}"
ES_INCLUDE : "{{ instance_default_file }}"
2016-01-19 11:50:02 +01:00
2016-03-18 19:30:11 +00:00
#This needs to removes any currently installed plugins
2015-05-13 13:33:43 +02:00
- name : Remove elasticsearch plugins
2016-03-18 19:30:11 +00:00
command : "{{es_home}}/bin/plugin remove {{item}} --silent"
2015-05-13 13:33:43 +02:00
ignore_errors : yes
2016-03-18 19:30:11 +00:00
with_items : installed_plugins.stdout_lines
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
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
#debug: var=item
2015-12-22 09:36:12 +00:00
command : "{{es_home}}/bin/plugin install {{ item.plugin }}{% if item.version is defined and item.version != '' %}/{{ item.version }}{% endif %} --silent"
2015-12-13 22:46:50 +00:00
register : plugin_installed
failed_when : "'Failed to install' in plugin_installed.stderr"
changed_when : plugin_installed.rc == 0
2015-05-13 13:33:43 +02:00
with_items : es_plugins
2016-03-18 19:30:11 +00:00
when : es_plugins is defined and not es_plugins is none
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
file : state=directory path={{ plugin_dir }} owner={{ es_user }} group={{ es_group }} recurse=yes