From 5d3616bd201dca724deaa0b34cb8790c78d6c7ef Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Sat, 23 Jul 2016 21:47:27 +0100 Subject: [PATCH] Support for removal for shield and license --- tasks/main.yml | 2 +- tasks/xpack/elasticsearch-xpack.yml | 31 +++++++++++++++------ tasks/xpack/shield/elasticsearch-shield.yml | 28 ++++++++++++++----- test/integration/xpack.yml | 1 - 4 files changed, 45 insertions(+), 17 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 422b0a3..cd2743b 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -27,8 +27,8 @@ when: es_plugins is defined or es_plugins_reinstall tags: - plugins + #We always execute xpack as we may need to remove features - include: xpack/elasticsearch-xpack.yml - when: es_enable_xpack tags: - xpack - include: elasticsearch-service.yml diff --git a/tasks/xpack/elasticsearch-xpack.yml b/tasks/xpack/elasticsearch-xpack.yml index 6087830..d779768 100644 --- a/tasks/xpack/elasticsearch-xpack.yml +++ b/tasks/xpack/elasticsearch-xpack.yml @@ -10,21 +10,36 @@ CONF_DIR: "{{ conf_dir }}" ES_INCLUDE: "{{ instance_default_file }}" -#Install License if not installed -- name: Install license plugin +#Remove license if installed and xpack not enabled +- name: Remove license plugin command: > - {{es_home}}/bin/plugin install license - register: license - failed_when: "'ERROR' in license_installed .stdout" - changed_when: license.rc == 1 - when: license_installed.rc == 1 + {{es_home}}/bin/plugin remove license + register: license_change + failed_when: "'ERROR' in license.stdout" + changed_when: license_change.rc == 1 + when: license_installed.rc == 0 and not es_enable_xpack notify: restart elasticsearch environment: CONF_DIR: "{{ conf_dir }}" ES_INCLUDE: "{{ instance_default_file }}" + +#Install License if not installed +- name: Install license plugin + command: > + {{es_home}}/bin/plugin install license + register: license_change + failed_when: "'ERROR' in license_change.stdout" + changed_when: license_change.rc == 0 + when: license_installed.rc == 1 and es_enable_xpack + notify: restart elasticsearch + environment: + CONF_DIR: "{{ conf_dir }}" + ES_INCLUDE: "{{ instance_default_file }}" + +#Include shield as we may need to remove it - include: shield/elasticsearch-shield.yml - when: '"shield" in es_xpack_features' +# when: '"shield" in es_xpack_features' #Any other xpacks plugins requiring configuration to be entered here diff --git a/tasks/xpack/shield/elasticsearch-shield.yml b/tasks/xpack/shield/elasticsearch-shield.yml index d199485..0612033 100644 --- a/tasks/xpack/shield/elasticsearch-shield.yml +++ b/tasks/xpack/shield/elasticsearch-shield.yml @@ -1,7 +1,6 @@ --- -#Test if we need to install shield - +#Test if shield is installed - shell: "{{es_home}}/bin/plugin list | sed -n '1!p' | grep shield" register: shield_installed changed_when: False @@ -11,14 +10,28 @@ ES_INCLUDE: "{{ instance_default_file }}" -#Install Shield if not installed +#Remove Shield if installed and its not been requested +- name: Remove shield plugin + command: > + {{es_home}}/bin/plugin remove shield + register: shield_change + failed_when: "'ERROR' in shield_change.stdout" + changed_when: shield_change.rc == 0 + when: shield_installed.rc == 0 and (not es_enable_xpack or not '"shield" in es_xpack_features') + notify: restart elasticsearch + environment: + CONF_DIR: "{{ conf_dir }}" + ES_INCLUDE: "{{ instance_default_file }}" + + +#Install Shield if not installed and its been requested - name: Install shield plugin command: > {{es_home}}/bin/plugin install shield - register: shield - failed_when: "'ERROR' in shield_installed.stdout" - changed_when: shield.rc == 1 - when: shield_installed.rc == 1 + register: shield_change + failed_when: "'ERROR' in shield_change.stdout" + changed_when: shield_change.rc == 0 + when: shield_installed.rc == 1 and es_enable_xpack and '"shield" in es_xpack_features' notify: restart elasticsearch environment: CONF_DIR: "{{ conf_dir }}" @@ -41,3 +54,4 @@ - name: Ensure shield conf directory exists file: path={{ conf_dir }}/shield state=directory owner={{ es_user }} group={{ es_group }} changed_when: False + when: es_enable_xpack and '"shield" in es_xpack_features' diff --git a/test/integration/xpack.yml b/test/integration/xpack.yml index f927ce8..f6fe157 100644 --- a/test/integration/xpack.yml +++ b/test/integration/xpack.yml @@ -8,7 +8,6 @@ es_enable_xpack: true es_xpack_features: - shield - - watcher es_api_basic_auth_username: es_admin es_api_basic_auth_password: changeMe es_users: