diff --git a/handlers/main.yml b/handlers/main.yml index aa746f0..ee37b75 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,7 +1,7 @@ - name: restart elasticsearch service: name={{instance_init_script | basename}} state=restarted enabled=yes - when: es_restart_on_change and es_start_service and not elasticsearch_started.changed and ((plugin_installed is defined and plugin_installed.changed) or (elasticsearch_install_from_repo.changed or elasticsearch_install_from_package.changed)) + when: es_restart_on_change and es_start_service and not elasticsearch_started.changed and ((plugin_installed is defined and plugin_installed.changed) or (xpack_state.changed) or (elasticsearch_install_from_repo.changed or elasticsearch_install_from_package.changed)) - name: load-native-realms include: ./handlers/shield/elasticsearch-shield-native.yml diff --git a/tasks/elasticsearch-plugins.yml b/tasks/elasticsearch-plugins.yml index 894533d..826ae08 100644 --- a/tasks/elasticsearch-plugins.yml +++ b/tasks/elasticsearch-plugins.yml @@ -26,6 +26,7 @@ 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 + register: plugin_installed environment: CONF_DIR: "{{ conf_dir }}" ES_INCLUDE: "{{ instance_default_file }}" @@ -46,4 +47,5 @@ #Set permissions on plugins directory - name: Set Plugin Directory Permissions - file: state=directory path={{ es_home }}/plugins owner={{ es_user }} group={{ es_group }} recurse=yes \ No newline at end of file + file: state=directory path={{ es_home }}/plugins owner={{ es_user }} group={{ es_group }} recurse=yes + when: es_enable_xpack \ No newline at end of file diff --git a/tasks/xpack/elasticsearch-xpack.yml b/tasks/xpack/elasticsearch-xpack.yml index d779768..5ce2a27 100644 --- a/tasks/xpack/elasticsearch-xpack.yml +++ b/tasks/xpack/elasticsearch-xpack.yml @@ -14,9 +14,9 @@ - name: Remove license plugin command: > {{es_home}}/bin/plugin remove license - register: license_change - failed_when: "'ERROR' in license.stdout" - changed_when: license_change.rc == 1 + register: xpack_state + failed_when: "'ERROR' in xpack_state.stdout" + changed_when: xpack_state.rc == 0 when: license_installed.rc == 0 and not es_enable_xpack notify: restart elasticsearch environment: @@ -28,9 +28,9 @@ - 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 + register: xpack_state + failed_when: "'ERROR' in xpack_state.stdout" + changed_when: xpack_state.rc == 0 when: license_installed.rc == 1 and es_enable_xpack notify: restart elasticsearch environment: diff --git a/tasks/xpack/shield/elasticsearch-shield.yml b/tasks/xpack/shield/elasticsearch-shield.yml index 0612033..dad8525 100644 --- a/tasks/xpack/shield/elasticsearch-shield.yml +++ b/tasks/xpack/shield/elasticsearch-shield.yml @@ -14,9 +14,9 @@ - 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 + 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') notify: restart elasticsearch environment: @@ -28,9 +28,9 @@ - name: Install shield plugin command: > {{es_home}}/bin/plugin install shield - register: shield_change - failed_when: "'ERROR' in shield_change.stdout" - changed_when: shield_change.rc == 0 + register: xpack_state + failed_when: "'ERROR' in xpack_state.stdout" + changed_when: xpack_state.rc == 0 when: shield_installed.rc == 1 and es_enable_xpack and '"shield" in es_xpack_features' notify: restart elasticsearch environment: