Support for all xpack features through generic install + improved tests
This commit is contained in:
parent
fdf1bda155
commit
57fa9e432b
11 changed files with 87 additions and 53 deletions
40
tasks/xpack/elasticsearch-xpack-install.yml
Normal file
40
tasks/xpack/elasticsearch-xpack-install.yml
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
---
|
||||
|
||||
- set_fact: es_version_changed=((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))
|
||||
|
||||
#Test if feature is installed
|
||||
- shell: "{{es_home}}/bin/plugin list | sed -n '1!p' | grep {{item}}"
|
||||
register: feature_installed
|
||||
changed_when: False
|
||||
ignore_errors: yes
|
||||
environment:
|
||||
CONF_DIR: "{{ conf_dir }}"
|
||||
ES_INCLUDE: "{{ instance_default_file }}"
|
||||
|
||||
|
||||
#Remove Plugin if installed and its not been requested or the ES version has changed
|
||||
- name: Remove {{item}} plugin
|
||||
command: >
|
||||
{{es_home}}/bin/plugin remove shield
|
||||
register: xpack_state
|
||||
failed_when: "'ERROR' in xpack_state.stdout"
|
||||
changed_when: xpack_state.rc == 0
|
||||
when: feature_installed.rc == 0 and (not es_enable_xpack or not '"{{item}}" in es_xpack_features' or es_version_changed)
|
||||
notify: restart elasticsearch
|
||||
environment:
|
||||
CONF_DIR: "{{ conf_dir }}"
|
||||
ES_INCLUDE: "{{ instance_default_file }}"
|
||||
|
||||
|
||||
#Install plugin if not installed, or the es version has changed (so removed above), and its been requested
|
||||
- name: Install {{item}} plugin
|
||||
command: >
|
||||
{{es_home}}/bin/plugin install {{item}}
|
||||
register: xpack_state
|
||||
failed_when: "'ERROR' in xpack_state.stdout"
|
||||
changed_when: xpack_state.rc == 0
|
||||
when: (feature_installed.rc == 1 or es_version_changed) and es_enable_xpack and "{{item}}" in es_xpack_features
|
||||
notify: restart elasticsearch
|
||||
environment:
|
||||
CONF_DIR: "{{ conf_dir }}"
|
||||
ES_INCLUDE: "{{ instance_default_file }}"
|
||||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
- set_fact: es_version_changed=((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))
|
||||
|
||||
#enabling xpack installs the license. Not a xpack feature and does not need to be specified
|
||||
|
||||
#Check if license is installed
|
||||
- name: Check License is installed
|
||||
shell: >
|
||||
|
|
@ -26,7 +28,6 @@
|
|||
CONF_DIR: "{{ conf_dir }}"
|
||||
ES_INCLUDE: "{{ instance_default_file }}"
|
||||
|
||||
|
||||
#Install License if not installed, or it needs to be reinstalled due to ES change (above task will have removed), and its been requested.
|
||||
- name: Install license plugin
|
||||
command: >
|
||||
|
|
@ -40,11 +41,14 @@
|
|||
CONF_DIR: "{{ conf_dir }}"
|
||||
ES_INCLUDE: "{{ instance_default_file }}"
|
||||
|
||||
#Include shield as we may need to remove it or change it due to es_version_changed
|
||||
- include: shield/elasticsearch-shield.yml
|
||||
# when: '"shield" in es_xpack_features'
|
||||
#We loop on all as we may need to remove some features
|
||||
- include: elasticsearch-xpack-install.yml
|
||||
with_items: "{{supported_xpack_features}}"
|
||||
|
||||
#Any other xpacks plugins requiring configuration to be entered here
|
||||
#Shield configuration
|
||||
- include: shield/elasticsearch-shield.yml
|
||||
|
||||
#Add any feature specific configuration here
|
||||
|
||||
- name: Set Plugin Directory Permissions
|
||||
file: state=directory path={{ es_home }}/plugins owner={{ es_user }} group={{ es_group }} recurse=yes
|
||||
|
|
@ -1,41 +1,5 @@
|
|||
---
|
||||
|
||||
#Test if shield is installed
|
||||
- shell: "{{es_home}}/bin/plugin list | sed -n '1!p' | grep shield"
|
||||
register: shield_installed
|
||||
changed_when: False
|
||||
ignore_errors: yes
|
||||
environment:
|
||||
CONF_DIR: "{{ conf_dir }}"
|
||||
ES_INCLUDE: "{{ instance_default_file }}"
|
||||
|
||||
|
||||
#Remove Shield if installed and its not been requested or the ES version has changed
|
||||
- name: Remove shield plugin
|
||||
command: >
|
||||
{{es_home}}/bin/plugin remove shield
|
||||
register: xpack_state
|
||||
failed_when: "'ERROR' in xpack_state.stdout"
|
||||
changed_when: xpack_state.rc == 0
|
||||
when: shield_installed.rc == 0 and (not es_enable_xpack or not '"shield" in es_xpack_features' or es_version_changed)
|
||||
notify: restart elasticsearch
|
||||
environment:
|
||||
CONF_DIR: "{{ conf_dir }}"
|
||||
ES_INCLUDE: "{{ instance_default_file }}"
|
||||
|
||||
|
||||
#Install Shield if not installed, or the es version has changed (so removed above), and its been requested
|
||||
- name: Install shield plugin
|
||||
command: >
|
||||
{{es_home}}/bin/plugin install shield
|
||||
register: xpack_state
|
||||
failed_when: "'ERROR' in xpack_state.stdout"
|
||||
changed_when: xpack_state.rc == 0
|
||||
when: (shield_installed.rc == 1 or es_version_changed) and es_enable_xpack and '"shield" in es_xpack_features'
|
||||
notify: restart elasticsearch
|
||||
environment:
|
||||
CONF_DIR: "{{ conf_dir }}"
|
||||
ES_INCLUDE: "{{ instance_default_file }}"
|
||||
#Shield specific configuration done here
|
||||
|
||||
#TODO: 1. Skip users with no password defined or error 2. Passwords | length > 6
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue