ansible-role-elasticsearch/tasks/elasticsearch-plugins.yml

51 lines
2.7 KiB
YAML
Raw Normal View History

---
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-01-19 11:50:02 +01:00
- set_fact: es_plugins_reinstall=true
2016-07-20 13:15:51 +01:00
when: ((elasticsearch_install_from_package 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-01-19 11:50:02 +01:00
- set_fact: list_command="list"
- set_fact: list_command="--list"
when: es_version | version_compare('2.0', '<')
2016-01-19 11:50:02 +01:00
#List currently installed plugins - ignore xpack if > v 2.0
- shell: "{{es_home}}/bin/plugin {{list_command}} | sed -n '1!p' | cut -d '-' -f2-{% if {{es_version}} | version_compare('2.0', '>') %} | grep -vE 'shield|watcher|marvel-agent|graph'{% endif %}"
register: installed_plugins
changed_when: False
ignore_errors: yes
environment:
CONF_DIR: "{{ conf_dir }}"
ES_INCLUDE: "{{ instance_default_file }}"
2016-01-19 11:50:02 +01:00
#This needs to removes any currently installed plugins
- name: Remove elasticsearch plugins
command: "{{es_home}}/bin/plugin remove {{item}} --silent"
ignore_errors: yes
2016-03-25 11:20:23 +03: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]
notify: restart elasticsearch
2016-07-23 22:18:31 +01:00
register: plugin_installed
environment:
CONF_DIR: "{{ conf_dir }}"
ES_INCLUDE: "{{ instance_default_file }}"
- name: Install elasticsearch plugins
#debug: var=item
command: >
{{es_home}}/bin/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
register: plugin_installed
failed_when: "'ERROR' in plugin_installed.stdout"
changed_when: plugin_installed.rc == 0
2016-03-25 11:20:23 +03:00
with_items: "{{ es_plugins }}"
2016-05-25 19:24:58 +06:00
when: es_plugins is defined and not es_plugins is none and es_plugins_reinstall
notify: restart elasticsearch
environment:
CONF_DIR: "{{ conf_dir }}"
2015-12-22 09:33:45 +00:00
ES_INCLUDE: "{{ instance_default_file }}"
#Set permissions on plugins directory
- name: Set Plugin Directory Permissions
2016-07-23 22:18:31 +01:00
file: state=directory path={{ es_home }}/plugins owner={{ es_user }} group={{ es_group }} recurse=yes
when: es_enable_xpack