Address the issue [ansible-elasticsearch #4](https://github.com/elastic/ansible-elasticsearch/issues/4) which add proxy for plugin installation and more generally es_proxy_host and es_proxy_port for global usage. Right now, it’s only used for plugins installation. In the futur, it can be used (or defined) in the java_opts within the default file for instance (elasticsearch.j2)
44 lines
No EOL
1.6 KiB
YAML
44 lines
No EOL
1.6 KiB
YAML
---
|
|
|
|
#es_plugins_reinstall will be set to true if elasticsearch_install.changed i.e. we have changed ES version
|
|
- set_fact: es_plugins_reinstall=true
|
|
when: elasticsearch_install.changed
|
|
|
|
#List currently installed plugins
|
|
|
|
|
|
|
|
#This needs to removed installed plugins not those listed
|
|
- name: Remove elasticsearch plugins
|
|
command: "{{es_home}}/bin/plugin remove {{ item.plugin }} --silent"
|
|
ignore_errors: yes
|
|
with_items: es_plugins
|
|
when: es_plugins_reinstall
|
|
notify: restart elasticsearch
|
|
environment:
|
|
CONF_DIR: "{{ conf_dir }}"
|
|
|
|
- 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: "'Failed to install' in plugin_installed.stderr"
|
|
changed_when: plugin_installed.rc == 0
|
|
with_items: es_plugins
|
|
when: ansible_os_family == 'RedHat' or ansible_os_family == 'Debian'
|
|
notify: restart elasticsearch
|
|
environment:
|
|
CONF_DIR: "{{ conf_dir }}"
|
|
ES_INCLUDE: "{{ instance_default_file }}"
|
|
|
|
#Set permissions on plugins directory
|
|
- name: Set Plugin Directory Permissions
|
|
file: state=directory path={{ plugin_dir }} owner={{ es_user }} group={{ es_group }} recurse=yes |