* remove multi instances support The goal is to stop supporting installation of more than one node in the same host. This commit update the Ansible role README documentation and remove the multi instances kitchen test. * remove systemd and init.d templates As we no more need to support more than one node on the same host, we no more need to override init files provided by elasticsearch official packages. * remove file script feature File scripts have been removed since elasticsearch 6.0 (https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_scripting_changes.html#_file_scripts_removed) * remove custom user and custom group ES_USER and ES_GROUP settings are no longer supported (https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_packaging_changes.html#_configuring_custom_user_and_group_for_package_is_no_longer_allowed) * add upgrade procedure * use same task for license activation with and without authentication
87 lines
4.6 KiB
YAML
87 lines
4.6 KiB
YAML
---
|
|
|
|
# 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.
|
|
- name: set fact es_plugins_reinstall to true
|
|
set_fact: es_plugins_reinstall=true
|
|
when: (((debian_elasticsearch_install_from_repo is defined and debian_elasticsearch_install_from_repo.changed) or (redhat_elasticsearch_install_from_repo is defined and redhat_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
|
|
|
|
- name: set fact list_command
|
|
set_fact: list_command=""
|
|
#If we are reinstalling all plugins, e.g. to a version change, we need to remove all plugins (inc. x-pack) to install any plugins. Otherwise we don't consider x-pack so the role stays idempotent.
|
|
- name: set fact list_command check for x-pack
|
|
set_fact: list_command="| grep -vE 'x-pack'"
|
|
when: not es_plugins_reinstall
|
|
|
|
- name: remove x-pack plugin directory when it isn't a plugin
|
|
file:
|
|
dest: "{{ es_home }}/plugins/x-pack"
|
|
state: "absent"
|
|
when: es_open_xpack
|
|
|
|
#List currently installed plugins. We have to list the directories as the list commmand fails if the ES version is different than the plugin version.
|
|
- name: Check installed elasticsearch plugins
|
|
become: yes
|
|
shell: "ls {{es_home}}/plugins {{list_command}}"
|
|
register: installed_plugins
|
|
changed_when: False
|
|
ignore_errors: yes
|
|
environment:
|
|
CONF_DIR: "{{ es_conf_dir }}"
|
|
ES_PATH_CONF: "{{ es_conf_dir }}"
|
|
ES_INCLUDE: "{{ default_file }}"
|
|
check_mode: no
|
|
|
|
#if es_plugins_reinstall is set to true we remove ALL plugins
|
|
- name: set fact plugins_to_remove to install_plugins.stdout_lines
|
|
set_fact: plugins_to_remove="{{ installed_plugins.stdout_lines | default([]) }}"
|
|
when: es_plugins_reinstall
|
|
|
|
#if the plugins listed are different than those requested, we remove those installed but not listed in the config
|
|
- name: set fact plugins_to_remove to delete plugins installed but not listed in es_plugins
|
|
set_fact: plugins_to_remove="{{ installed_plugins.stdout_lines | difference(es_plugins | json_query('[*].plugin')) | default([]) }}"
|
|
when: not es_plugins_reinstall
|
|
|
|
#if es_plugins_reinstall is set to true we (re)install ALL plugins
|
|
- name: set fact plugins_to_install to es_plugins
|
|
set_fact: plugins_to_install="{{ es_plugins | json_query('[*].plugin') | default([]) }}"
|
|
when: es_plugins_reinstall
|
|
|
|
#if the plugins listed are different than those requested, we install those not installed but listed in the config
|
|
- name: set fact to plugins_to_install to those in es_config but not installed
|
|
set_fact: plugins_to_install="{{ es_plugins | json_query('[*].plugin') | difference(installed_plugins.stdout_lines) | default([]) }}"
|
|
when: not es_plugins_reinstall
|
|
|
|
# This removes any currently installed plugins (to prevent errors when reinstalling)
|
|
- name: Remove elasticsearch plugins
|
|
become: yes
|
|
command: "{{es_home}}/bin/elasticsearch-plugin remove {{item}} --silent"
|
|
with_items: "{{ plugins_to_remove | default([]) }}"
|
|
notify: restart elasticsearch
|
|
register: plugin_removed
|
|
environment:
|
|
CONF_DIR: "{{ es_conf_dir }}"
|
|
ES_PATH_CONF: "{{ es_conf_dir }}"
|
|
ES_INCLUDE: "{{ default_file }}"
|
|
|
|
- name: Install elasticsearch plugins
|
|
become: yes
|
|
command: "{{es_home}}/bin/elasticsearch-plugin install {{ item.url | default(item.plugin) }} --batch --silent"
|
|
register: plugin_installed
|
|
changed_when: plugin_installed.rc == 0
|
|
with_items: "{{ es_plugins }}"
|
|
when: item.plugin in plugins_to_install
|
|
notify: restart elasticsearch
|
|
environment:
|
|
CONF_DIR: "{{ es_conf_dir }}"
|
|
ES_PATH_CONF: "{{ es_conf_dir }}"
|
|
ES_INCLUDE: "{{ default_file }}"
|
|
ES_JAVA_OPTS: "{% if item.proxy_host is defined and item.proxy_host != '' and item.proxy_port is defined and item.proxy_port != ''%} -Dhttp.proxyHost={{ item.proxy_host }} -Dhttp.proxyPort={{ item.proxy_port }} -Dhttps.proxyHost={{ item.proxy_host }} -Dhttps.proxyPort={{ item.proxy_port }} {% elif es_proxy_host is defined and es_proxy_host != '' %} -Dhttp.proxyHost={{ es_proxy_host }} -Dhttp.proxyPort={{ es_proxy_port }} -Dhttps.proxyHost={{ es_proxy_host }} -Dhttps.proxyPort={{ es_proxy_port }} {% endif %}"
|
|
until: plugin_installed.rc == 0
|
|
retries: 5
|
|
delay: 5
|
|
|
|
#Set permissions on plugins directory
|
|
- name: Set Plugin Directory Permissions
|
|
become: yes
|
|
file: state=directory path={{ es_home }}/plugins owner={{ es_user }} group={{ es_group }} recurse=yes
|