From 9eacd3a5e0155ff5982e539f4feeee7079e5ff08 Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Sun, 24 Jul 2016 17:39:44 +0100 Subject: [PATCH] Fix for detecting es version changed --- tasks/elasticsearch-plugins.yml | 3 ++- tasks/xpack/elasticsearch-xpack-install.yml | 2 -- tasks/xpack/elasticsearch-xpack.yml | 9 ++++++--- test/integration/helpers/serverspec/xpack_spec.rb | 9 +++++++++ test/integration/xpack.yml | 3 +++ 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/tasks/elasticsearch-plugins.yml b/tasks/elasticsearch-plugins.yml index aa8c291..63488b2 100644 --- a/tasks/elasticsearch-plugins.yml +++ b/tasks/elasticsearch-plugins.yml @@ -11,8 +11,9 @@ when: es_version | version_compare('2.0', '<') #List currently installed plugins - ignore xpack if > v 2.0 -- shell: "{{es_home}}/bin/plugin {{list_command}} | sed -n '1!p' | cut -d '-' -f2-{% if es_version | version_compare('2.0', '>') %} | grep -vE '{{supported_xpack_features | join('|')}}'{% endif %}" +- shell: "{{es_home}}/bin/plugin {{list_command}} | sed -n '1!p' | cut -d '-' -f2-{% if es_version | version_compare('2.0', '>') %} | grep -vE '{{supported_xpack_features | join('|')}}|license'{% endif %}" register: installed_plugins + failed_when: "'ERROR' in installed_plugins.stdout" changed_when: False ignore_errors: yes environment: diff --git a/tasks/xpack/elasticsearch-xpack-install.yml b/tasks/xpack/elasticsearch-xpack-install.yml index 397aaed..dfe7962 100644 --- a/tasks/xpack/elasticsearch-xpack-install.yml +++ b/tasks/xpack/elasticsearch-xpack-install.yml @@ -1,7 +1,5 @@ --- -- 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 diff --git a/tasks/xpack/elasticsearch-xpack.yml b/tasks/xpack/elasticsearch-xpack.yml index db0a112..d83fa38 100644 --- a/tasks/xpack/elasticsearch-xpack.yml +++ b/tasks/xpack/elasticsearch-xpack.yml @@ -1,8 +1,10 @@ --- -- 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)) +- 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 + +- debug: msg="{{es_version_changed}}" +#enabling xpack installs the license. Not a xpack feature and does not need to be specified - TODO: we should append it to the list if xpack is enabled and remove this #Check if license is installed - name: Check License is installed @@ -10,6 +12,7 @@ {{es_home}}/bin/plugin list | tail -n +2 | grep license register: license_installed ignore_errors: yes + failed_when: "'ERROR' in license_installed.stdout" changed_when: False environment: CONF_DIR: "{{ conf_dir }}" @@ -41,7 +44,7 @@ CONF_DIR: "{{ conf_dir }}" ES_INCLUDE: "{{ instance_default_file }}" -#We loop on all as we may need to remove some features +#We loop on all as we may need to remove some features. - include: elasticsearch-xpack-install.yml with_items: "{{supported_xpack_features}}" diff --git a/test/integration/helpers/serverspec/xpack_spec.rb b/test/integration/helpers/serverspec/xpack_spec.rb index ef871a5..57117e6 100644 --- a/test/integration/helpers/serverspec/xpack_spec.rb +++ b/test/integration/helpers/serverspec/xpack_spec.rb @@ -111,6 +111,15 @@ shared_examples 'xpack::init' do |es_version| its(:exit_status) { should eq 0 } end + describe file('/usr/share/elasticsearch/plugins/kopf') do + it { should be_directory } + it { should be_owned_by 'elasticsearch' } + end + + describe command('curl -s localhost:9200/_nodes/plugins?pretty=true -u es_admin:changeMe | grep kopf') do + its(:exit_status) { should eq 0 } + end + #test we haven't installed graph or marvel-agent describe file('/usr/share/elasticsearch/plugins/graph') do diff --git a/test/integration/xpack.yml b/test/integration/xpack.yml index 71096c0..fb22b60 100644 --- a/test/integration/xpack.yml +++ b/test/integration/xpack.yml @@ -8,6 +8,9 @@ vars: es_templates: true es_enable_xpack: true + es_plugins: + - plugin: lmenezes/elasticsearch-kopf + version: master es_xpack_features: - shield - watcher