From fe0fc4b4308ad2ec59d1bb50070a4fcdd760623e Mon Sep 17 00:00:00 2001 From: Michael Russell Date: Wed, 21 Feb 2018 21:09:15 +0100 Subject: [PATCH 1/3] Bump default version to 6.2.2 and 5.6.8 --- .kitchen.yml | 2 +- defaults/main.yml | 2 +- tasks/elasticsearch-config.yml | 14 ++++++++++---- test/integration/helpers/serverspec/config_spec.rb | 12 ++++++++---- test/integration/helpers/serverspec/multi_spec.rb | 12 ++++++++---- .../integration/helpers/serverspec/package_spec.rb | 12 ++++++++---- .../helpers/serverspec/standard_spec.rb | 12 ++++++++---- test/integration/helpers/serverspec/xpack_spec.rb | 12 ++++++++---- .../helpers/serverspec/xpack_standard_spec.rb | 12 ++++++++---- 9 files changed, 60 insertions(+), 30 deletions(-) diff --git a/.kitchen.yml b/.kitchen.yml index 3f303e07..a8d440ad 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -21,7 +21,7 @@ provisioner: extra_vars: es_major_version: "<%= ENV['VERSION'] %>" <% if ENV['VERSION'] == '5.x' %> - es_version: '5.6.7' + es_version: '5.6.8' <% end %> <% end %> diff --git a/defaults/main.yml b/defaults/main.yml index 1b1271db..002c553e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,6 +1,6 @@ --- es_major_version: "6.x" -es_version: "6.1.3" +es_version: "6.2.2" es_version_lock: false es_use_repository: true es_templates_fileglob: "files/templates/*.json" diff --git a/tasks/elasticsearch-config.yml b/tasks/elasticsearch-config.yml index 0f08a628..987de718 100644 --- a/tasks/elasticsearch-config.yml +++ b/tasks/elasticsearch-config.yml @@ -70,14 +70,20 @@ become: yes file: dest=/etc/init.d/elasticsearch state=absent -- name: Delete Default Environment File +- name: Create empty default environment file become: yes - file: dest=/etc/default/elasticsearch state=absent + changed_when: False + copy: + dest: /etc/default/elasticsearch + content: '' when: ansible_os_family == 'Debian' -- name: Delete Default Environment File +- name: Create empty default environment file become: yes - file: dest=/etc/sysconfig/elasticsearch state=absent + changed_when: False + copy: + dest: /etc/sysconfig/elasticsearch + content: '' when: ansible_os_family == 'RedHat' - name: Delete Default Sysconfig File diff --git a/test/integration/helpers/serverspec/config_spec.rb b/test/integration/helpers/serverspec/config_spec.rb index 148ade01..424a11ad 100644 --- a/test/integration/helpers/serverspec/config_spec.rb +++ b/test/integration/helpers/serverspec/config_spec.rb @@ -113,12 +113,16 @@ it { should_not exist } end - describe file('/etc/default/elasticsearch') do - it { should_not exist } + if ['debian', 'ubuntu'].include?(os[:family]) + describe file('/etc/default/elasticsearch') do + its(:content) { should match '' } + end end - describe file('/etc/sysconfig/elasticsearch') do - it { should_not exist } + if ['centos', 'redhat'].include?(os[:family]) + describe file('/etc/sysconfig/elasticsearch') do + its(:content) { should match '' } + end end describe file('/usr/lib/systemd/system/elasticsearch.service') do diff --git a/test/integration/helpers/serverspec/multi_spec.rb b/test/integration/helpers/serverspec/multi_spec.rb index 614284cb..6d8062d5 100644 --- a/test/integration/helpers/serverspec/multi_spec.rb +++ b/test/integration/helpers/serverspec/multi_spec.rb @@ -200,12 +200,16 @@ it { should_not exist } end - describe file('/etc/default/elasticsearch') do - it { should_not exist } + if ['debian', 'ubuntu'].include?(os[:family]) + describe file('/etc/default/elasticsearch') do + its(:content) { should match '' } + end end - describe file('/etc/sysconfig/elasticsearch') do - it { should_not exist } + if ['centos', 'redhat'].include?(os[:family]) + describe file('/etc/sysconfig/elasticsearch') do + its(:content) { should match '' } + end end describe file('/usr/lib/systemd/system/elasticsearch.service') do diff --git a/test/integration/helpers/serverspec/package_spec.rb b/test/integration/helpers/serverspec/package_spec.rb index 947ce875..bf85760f 100644 --- a/test/integration/helpers/serverspec/package_spec.rb +++ b/test/integration/helpers/serverspec/package_spec.rb @@ -88,12 +88,16 @@ it { should_not exist } end - describe file('/etc/default/elasticsearch') do - it { should_not exist } + if ['debian', 'ubuntu'].include?(os[:family]) + describe file('/etc/default/elasticsearch') do + its(:content) { should match '' } + end end - describe file('/etc/sysconfig/elasticsearch') do - it { should_not exist } + if ['centos', 'redhat'].include?(os[:family]) + describe file('/etc/sysconfig/elasticsearch') do + its(:content) { should match '' } + end end describe file('/usr/lib/systemd/system/elasticsearch.service') do diff --git a/test/integration/helpers/serverspec/standard_spec.rb b/test/integration/helpers/serverspec/standard_spec.rb index 59b9f2a0..ca4b3f2b 100644 --- a/test/integration/helpers/serverspec/standard_spec.rb +++ b/test/integration/helpers/serverspec/standard_spec.rb @@ -60,12 +60,16 @@ it { should_not exist } end - describe file('/etc/default/elasticsearch') do - it { should_not exist } + if ['debian', 'ubuntu'].include?(os[:family]) + describe file('/etc/default/elasticsearch') do + its(:content) { should match '' } + end end - describe file('/etc/sysconfig/elasticsearch') do - it { should_not exist } + if ['centos', 'redhat'].include?(os[:family]) + describe file('/etc/sysconfig/elasticsearch') do + its(:content) { should match '' } + end end describe file('/usr/lib/systemd/system/elasticsearch.service') do diff --git a/test/integration/helpers/serverspec/xpack_spec.rb b/test/integration/helpers/serverspec/xpack_spec.rb index f55d4e71..8d2e8960 100644 --- a/test/integration/helpers/serverspec/xpack_spec.rb +++ b/test/integration/helpers/serverspec/xpack_spec.rb @@ -56,12 +56,16 @@ it { should_not exist } end - describe file('/etc/default/elasticsearch') do - it { should_not exist } + if ['debian', 'ubuntu'].include?(os[:family]) + describe file('/etc/default/elasticsearch') do + its(:content) { should match '' } + end end - describe file('/etc/sysconfig/elasticsearch') do - it { should_not exist } + if ['centos', 'redhat'].include?(os[:family]) + describe file('/etc/sysconfig/elasticsearch') do + its(:content) { should match '' } + end end describe file('/usr/lib/systemd/system/elasticsearch.service') do diff --git a/test/integration/helpers/serverspec/xpack_standard_spec.rb b/test/integration/helpers/serverspec/xpack_standard_spec.rb index e19b2848..f3d39a52 100644 --- a/test/integration/helpers/serverspec/xpack_standard_spec.rb +++ b/test/integration/helpers/serverspec/xpack_standard_spec.rb @@ -57,12 +57,16 @@ it { should_not exist } end - describe file('/etc/default/elasticsearch') do - it { should_not exist } + if ['debian', 'ubuntu'].include?(os[:family]) + describe file('/etc/default/elasticsearch') do + its(:content) { should match '' } + end end - describe file('/etc/sysconfig/elasticsearch') do - it { should_not exist } + if ['centos', 'redhat'].include?(os[:family]) + describe file('/etc/sysconfig/elasticsearch') do + its(:content) { should match '' } + end end describe file('/usr/lib/systemd/system/elasticsearch.service') do From d9d54917bd707ade7bc9da2ec78c80dd7ca7472e Mon Sep 17 00:00:00 2001 From: Michael Russell Date: Thu, 22 Feb 2018 10:01:16 +0100 Subject: [PATCH 2/3] X-pack plugin has been renamed to x-pack-core --- .../helpers/serverspec/xpack_standard_spec.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test/integration/helpers/serverspec/xpack_standard_spec.rb b/test/integration/helpers/serverspec/xpack_standard_spec.rb index f3d39a52..f6f156c6 100644 --- a/test/integration/helpers/serverspec/xpack_standard_spec.rb +++ b/test/integration/helpers/serverspec/xpack_standard_spec.rb @@ -120,8 +120,18 @@ it { should be_owned_by 'elasticsearch' } end - describe command('curl -s localhost:9200/_nodes/plugins | grep \'"name":"x-pack","version":"'+vars['es_version']+'"\'') do - its(:exit_status) { should eq 0 } + describe 'x-pack-core plugin' do + it 'should be installed with the correct version' do + plugins = curl_json('http://localhost:9200/_nodes/plugins') + node, data = plugins['nodes'].first + version = 'plugin not found' + data['plugins'].each do |plugin| + if plugin['name'] == 'x-pack-core' + version = plugin['version'] + end + end + expect(version).to eql(vars['es_version']) + end end #Test users file, users_roles and roles.yml From 38982ba6ad0bb20342c00c694cc6f872b2fa6d1c Mon Sep 17 00:00:00 2001 From: Michael Russell Date: Thu, 22 Feb 2018 11:14:25 +0100 Subject: [PATCH 3/3] Only change name to x-pack-core for 6.2 and above --- .../helpers/serverspec/xpack_standard_spec.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/integration/helpers/serverspec/xpack_standard_spec.rb b/test/integration/helpers/serverspec/xpack_standard_spec.rb index f6f156c6..545fbbc8 100644 --- a/test/integration/helpers/serverspec/xpack_standard_spec.rb +++ b/test/integration/helpers/serverspec/xpack_standard_spec.rb @@ -125,8 +125,15 @@ plugins = curl_json('http://localhost:9200/_nodes/plugins') node, data = plugins['nodes'].first version = 'plugin not found' + + if Gem::Version.new(vars['es_version']) >= Gem::Version.new('6.2') + name = 'x-pack-core' + else + name = 'x-pack' + end + data['plugins'].each do |plugin| - if plugin['name'] == 'x-pack-core' + if plugin['name'] == name version = plugin['version'] end end