Remove multi instances support (#566)

* remove multi instances support
The goal is to stop supporting installation of more than one node in the same host. This commit update the Ansible role README documentation and remove the multi instances kitchen test.

* remove systemd and init.d templates
As we no more need to support more than one node on the same host, we no more need to override init files provided by elasticsearch official packages.

* remove file script feature
File scripts have been removed since elasticsearch 6.0 (https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_scripting_changes.html#_file_scripts_removed)

* remove custom user and custom group
ES_USER and ES_GROUP settings are no longer supported (https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_packaging_changes.html#_configuring_custom_user_and_group_for_package_is_no_longer_allowed)

* add upgrade procedure

* use same task for license activation with and without authentication
This commit is contained in:
Julien Mailleret 2019-06-03 14:18:09 +02:00 committed by GitHub
parent 25bd09f683
commit 2cb020a4c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 176 additions and 1053 deletions

View file

@ -1,122 +0,0 @@
require 'spec_helper'
require 'json'
vars = JSON.parse(File.read('/tmp/vars.json'))
shared_examples 'multi::init' do |vars|
describe service('master_elasticsearch') do
it { should be_running }
end
#test configuration parameters have been set - test all appropriately set in config file
describe file("/etc/elasticsearch/#{vars['es_instance_name']}/elasticsearch.yml") do
it { should be_file }
it { should contain 'http.port: 9201' }
if vars['es_major_version'] == '7.x'
it { should contain 'transport.port: 9301' }
else
it { should contain 'transport.tcp.port: 9301' }
end
it { should_not contain 'bootstrap.memory_lock: true' }
end
#test configuration parameters have been set for master - test all appropriately set in config file
describe file('/etc/elasticsearch/master/elasticsearch.yml') do
it { should be_file }
it { should contain 'http.port: 9200' }
if vars['es_major_version'] == '7.x'
it { should contain 'transport.port: 9300' }
else
it { should contain 'transport.tcp.port: 9300' }
end
it { should contain 'node.data: false' }
it { should contain 'node.master: true' }
it { should contain 'node.name: localhost-master' }
it { should contain 'bootstrap.memory_lock: true' }
it { should_not contain 'path.conf: /etc/elasticsearch/master' }
it { should contain 'path.data: /opt/elasticsearch/master/localhost-master' }
it { should contain 'path.logs: /var/log/elasticsearch/localhost-master' }
end
describe 'Master listening' do
it 'listening in port 9200' do
expect(port 9200).to be_listening
end
end
#test we started on the correct port was used for master
describe 'master started' do
it 'master node should be running', :retry => 3, :retry_wait => 10 do
expect(curl_json('http://localhost:9200')['name']).to eq('localhost-master')
end
end
#test we started on the correct port was used for node 1
describe "#{vars['es_instance_name']} started" do
it 'node should be running', :retry => 3, :retry_wait => 10 do
expect(curl_json('http://localhost:9201')['name']).to eq("localhost-#{vars['es_instance_name']}")
end
end
#Confirm that the data directory has only been set for the first node
describe file('/opt/elasticsearch/master/localhost-master') do
it { should be_directory }
it { should be_owned_by 'elasticsearch' }
end
describe file("/opt/elasticsearch/data-1/localhost-#{vars['es_instance_name']}") do
it { should be_directory }
it { should be_owned_by 'elasticsearch' }
end
describe file("/opt/elasticsearch/data-2/localhost-#{vars['es_instance_name']}") do
it { should be_directory }
it { should be_owned_by 'elasticsearch' }
end
#test to make sure mlock was applied
describe command('curl -s "localhost:9200/_nodes/localhost-master/process?pretty=true" | grep mlockall') do
its(:stdout) { should match /true/ }
its(:exit_status) { should eq 0 }
end
#test to make sure mlock was not applied
describe command("curl -s 'localhost:9201/_nodes/localhost-#{vars['es_instance_name']}/process?pretty=true' | grep mlockall") do
its(:stdout) { should match /false/ }
its(:exit_status) { should eq 0 }
end
describe 'version check on master' do
it 'should be reported as version '+vars['es_version'] do
command = command('curl -s localhost:9200 | grep number')
expect(command.stdout).to match(vars['es_version'])
expect(command.exit_status).to eq(0)
end
end
describe 'version check on data' do
it 'should be reported as version '+vars['es_version'] do
command = command('curl -s localhost:9201 | grep number')
expect(command.stdout).to match(vars['es_version'])
expect(command.exit_status).to eq(0)
end
end
for plugin in vars['es_plugins']
plugin = plugin['plugin']
describe command('curl -s localhost:9200/_nodes/plugins?pretty=true | grep '+plugin) do
its(:exit_status) { should eq 0 }
end
describe command('curl -s localhost:9201/_nodes/plugins?pretty=true | grep '+plugin) do
its(:exit_status) { should eq 0 }
end
describe file('/usr/share/elasticsearch/plugins/'+plugin) do
it { should be_directory }
it { should be_owned_by 'elasticsearch' }
end
end
end

View file

@ -1,12 +1,12 @@
require 'spec_helper'
shared_examples 'oss::init' do |vars|
describe file("/etc/elasticsearch/#{vars['es_instance_name']}/log4j2.properties") do
describe file("/etc/elasticsearch/log4j2.properties") do
it { should be_file }
it { should be_owned_by 'elasticsearch' }
it { should_not contain 'CUSTOM LOG4J FILE' }
end
describe file("/etc/elasticsearch/#{vars['es_instance_name']}/jvm.options") do
describe file("/etc/elasticsearch/jvm.options") do
it { should be_file }
it { should be_owned_by vars['es_user'] }
end

View file

@ -97,7 +97,7 @@ shared_examples 'shared::init' do |vars|
it { should be_installed }
end
describe service("#{vars['es_instance_name']}_elasticsearch") do
describe service("elasticsearch") do
it { should be_running }
end
@ -128,22 +128,11 @@ shared_examples 'shared::init' do |vars|
end
end
end
describe file('/etc/init.d/elasticsearch') do
it { should_not exist }
end
describe file(family['defaults_path']) do
its(:content) { should match '' }
end
describe file('/etc/elasticsearch/elasticsearch.yml') do
it { should_not exist }
end
describe file('/etc/elasticsearch/logging.yml') do
it { should_not exist }
end
if vars.key?('es_plugins')
vars['es_plugins'].each do |plugin|
name = plugin['plugin']
@ -162,12 +151,12 @@ shared_examples 'shared::init' do |vars|
end
end
end
describe file("/etc/elasticsearch/#{vars['es_instance_name']}/elasticsearch.yml") do
it { should contain "node.name: localhost-#{vars['es_instance_name']}" }
describe file("/etc/elasticsearch/elasticsearch.yml") do
it { should contain "node.name: localhost" }
it { should contain 'cluster.name: elasticsearch' }
it { should_not contain "path.conf: /etc/elasticsearch/#{vars['es_instance_name']}" }
its(:content) { should match "path.data: #{vars['data_dirs'].join(',')}" }
its(:content) { should match "path.logs: /var/log/elasticsearch/localhost-#{vars['es_instance_name']}" }
it { should_not contain "path.conf: /etc/elasticsearch" }
its(:content) { should match "path.data: #{vars['es_data_dirs'].join(',')}" }
its(:content) { should match "path.logs: /var/log/elasticsearch" }
end
if vars['es_use_repository']

View file

@ -4,13 +4,13 @@ vars = JSON.parse(File.read('/tmp/vars.json'))
shared_examples 'xpack_upgrade::init' do |vars|
#Test users file, users_roles and roles.yml
describe file("/etc/elasticsearch/#{vars['es_instance_name']}#{vars['es_xpack_conf_subdir']}/users_roles") do
describe file("/etc/elasticsearch/#{vars['es_xpack_conf_subdir']}/users_roles") do
it { should be_owned_by 'elasticsearch' }
it { should contain 'admin:es_admin' }
it { should contain 'power_user:testUser' }
end
describe file("/etc/elasticsearch/#{vars['es_instance_name']}#{vars['es_xpack_conf_subdir']}/users") do
describe file("/etc/elasticsearch/#{vars['es_xpack_conf_subdir']}/users") do
it { should be_owned_by 'elasticsearch' }
it { should contain 'testUser:' }
it { should contain 'es_admin:' }
@ -23,7 +23,7 @@ shared_examples 'xpack_upgrade::init' do |vars|
end
end
describe file("/etc/elasticsearch/#{vars['es_instance_name']}/elasticsearch.yml") do
describe file("/etc/elasticsearch/elasticsearch.yml") do
if vars['es_major_version'] == '7.x'
it { should contain 'security.authc.realms.file.file1.order: 0' }
it { should contain 'security.authc.realms.native.native1.order: 1' }
@ -36,7 +36,7 @@ shared_examples 'xpack_upgrade::init' do |vars|
end
#Test contents of role_mapping.yml
describe file("/etc/elasticsearch/#{vars['es_instance_name']}#{vars['es_xpack_conf_subdir']}/role_mapping.yml") do
describe file("/etc/elasticsearch/#{vars['es_xpack_conf_subdir']}/role_mapping.yml") do
it { should be_owned_by 'elasticsearch' }
it { should contain 'power_user:' }
it { should contain '- cn=admins,dc=example,dc=com' }

View file

@ -10,13 +10,11 @@
roles:
- elasticsearch
vars:
es_instance_name: "security_node"
es_xpack_license: "{{ lookup('file', '/tmp/license.json') }}"
es_config:
xpack.security.authc.realms.file.file1.order: 1
xpack.security.authc.realms.native.native1.type: "native"
es_heap_size: "1g"
es_enable_xpack: true
es_plugins:
- plugin: ingest-attachment
es_xpack_features:

View file

@ -1,63 +0,0 @@
---
# Test ability to deploy multiple instances to a machine
- name: Elasticsearch Multi test - master on 9200
hosts: localhost
post_tasks:
- include: elasticsearch/test/integration/debug.yml
roles:
- elasticsearch
vars:
es_instance_name: "master"
es_data_dirs:
- "/opt/elasticsearch/master"
es_config_6x:
discovery.zen.ping.unicast.hosts: "localhost:9300"
http.port: 9200
transport.tcp.port: 9300
node.data: false
node.master: true
bootstrap.memory_lock: true
es_config_7x:
http.port: 9200
transport.port: 9300
node.data: false
node.master: true
bootstrap.memory_lock: true
es_config: "{{ es_config_7x if es_major_version == '7.x' else es_config_6x }}"
es_enable_xpack: false
es_templates: true
es_heap_size: "1g"
es_api_port: 9200
es_plugins:
- plugin: ingest-attachment
- name: Elasticsearch Multi test - data on 9201
hosts: localhost
post_tasks:
- include: elasticsearch/test/integration/debug.yml
roles:
- elasticsearch
vars:
es_enable_xpack: false
es_templates: true
es_heap_size: "1g"
es_api_port: 9201
es_plugins:
- plugin: ingest-attachment
es_instance_name: "node1"
es_data_dirs:
- "/opt/elasticsearch/data-1"
- "/opt/elasticsearch/data-2"
es_config_6x:
discovery.zen.ping.unicast.hosts: "localhost:9300"
http.port: 9201
transport.tcp.port: 9301
node.data: true
node.master: false
es_config_7x:
discovery.seed_hosts: "localhost:9300"
http.port: 9201
transport.port: 9301
node.data: true
node.master: false
es_config: "{{ es_config_7x if es_major_version == '7.x' else es_config_6x }}"

View file

@ -1,2 +0,0 @@
---
- host: test-kitchen

View file

@ -1,9 +0,0 @@
require 'multi_spec'
require 'shared_spec'
require 'json'
vars = JSON.parse(File.read('/tmp/vars.json'))
describe 'Multi Tests' do
include_examples 'shared::init', vars
include_examples 'multi::init', vars
end

View file

@ -6,7 +6,6 @@
roles:
- elasticsearch
vars:
es_instance_name: "node1"
es_version: "{{ '7.0.0' if es_major_version == '7.x' else '6.7.1' }}" # This is set to an older version than the current default to force an upgrade
es_enable_xpack: false
es_heap_size: "1g"
@ -18,7 +17,6 @@
roles:
- elasticsearch
vars:
es_instance_name: "node1"
es_enable_xpack: true
es_heap_size: "1g"
es_xpack_features:

View file

@ -6,7 +6,6 @@
roles:
- elasticsearch
vars:
es_instance_name: "node1"
es_version: "{{ '7.0.0' if es_major_version == '7.x' else '6.7.1' }}" # This is set to an older version than the current default to force an upgrade
es_enable_xpack: false
es_heap_size: "1g"
@ -18,6 +17,5 @@
roles:
- elasticsearch
vars:
es_instance_name: "node1"
es_enable_xpack: false
es_heap_size: "1g"

View file

@ -6,7 +6,6 @@
roles:
- elasticsearch
vars:
es_instance_name: "node1"
es_enable_xpack: false
es_heap_size: "1g"
es_plugins:

View file

@ -6,8 +6,6 @@
roles:
- elasticsearch
vars:
es_instance_name: "node1"
es_api_port: 9200
es_config_6x:
http.port: 9200
xpack.security.authc.realms.file1.order: 0
@ -23,7 +21,6 @@
es_templates: true
es_major_version: "7.x"
es_version: "{{ '7.0.0' if es_major_version == '7.x' else '6.7.1' }}" # This is set to an older version than the current default to force an upgrade
es_enable_xpack: true
es_xpack_license: "{{ lookup('file', '/tmp/license.json') }}"
es_plugins:
- plugin: ingest-attachment
@ -119,8 +116,6 @@
roles:
- elasticsearch
vars:
es_api_port: 9200
es_instance_name: "node1"
es_config_6x:
http.port: 9200
xpack.security.authc.realms.file1.order: 0
@ -134,7 +129,6 @@
es_config: "{{ es_config_7x if es_major_version == '7.x' else es_config_6x }}"
es_heap_size: "1g"
es_templates: true
es_enable_xpack: true
es_xpack_license: "{{ lookup('file', '/tmp/license.json') }}"
es_plugins:
- plugin: ingest-attachment

View file

@ -7,10 +7,7 @@
roles:
- elasticsearch
vars:
es_api_port: 9200
es_instance_name: "node1"
es_config:
http.port: 9200
es_xpack_custom_url: "https://artifacts.elastic.co/downloads/packs/x-pack/x-pack-{{ es_version }}.zip"
es_heap_size: 2g
es_enable_xpack: true