Skip to content

Commit c9bcd91

Browse files
author
Gavin Williams
authored
Merge pull request #1104 from elastic/bump_default_es_version
Bump Elasticsearch version and some cleanup
2 parents 873058e + 4003e47 commit c9bcd91

File tree

22 files changed

+159
-1361
lines changed

22 files changed

+159
-1361
lines changed

.fixtures.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fixtures:
1111
ref: 4.13.1
1212
java:
1313
repo: puppetlabs/java
14-
ref: 6.2.0
14+
ref: 6.5.0
1515
concat:
1616
repo: puppetlabs/concat
1717
ref: 2.2.1

.travis.yml

Lines changed: 14 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,11 @@ language: ruby
1111
script: travis_retry bundle exec rake $TASK
1212
jobs:
1313
allow_failures:
14-
- env:
15-
- TASK=beaker:ubuntu-server-1404-x64:snapshot
16-
- env:
17-
- OSS_PACKAGE=true
18-
- TASK=beaker:ubuntu-server-1404-x64:snapshot
1914
- env:
2015
- TASK=beaker:ubuntu-server-1604-x64:snapshot
2116
- env:
2217
- OSS_PACKAGE=true
2318
- TASK=beaker:ubuntu-server-1604-x64:snapshot
24-
- env:
25-
- TASK=beaker:centos-6-x64:snapshot
26-
- env:
27-
- OSS_PACKAGE=true
28-
- TASK=beaker:centos-6-x64:snapshot
2919
- env:
3020
- TASK=beaker:centos-7-x64:snapshot
3121
- env:
@@ -54,101 +44,73 @@ jobs:
5444
- TASK=beaker:amazonlinux-1-x64:acceptance
5545
- env:
5646
- BEAKER_PUPPET_COLLECTION=puppet6
57-
- TASK=beaker:amazonlinux-1-x64:acceptance[7.8.0]
47+
- TASK=beaker:amazonlinux-1-x64:acceptance[6.8.12]
5848
- env:
5949
- BEAKER_PUPPET_COLLECTION=puppet6
6050
- TASK=beaker:amazonlinux-2-x64:acceptance
6151
- env:
6252
- BEAKER_PUPPET_COLLECTION=puppet6
63-
- TASK=beaker:amazonlinux-2-x64:acceptance[7.8.0]
64-
- env:
65-
- BEAKER_PUPPET_COLLECTION=puppet6
66-
- TASK=beaker:centos-6-x64:acceptance
67-
- env:
68-
- BEAKER_PUPPET_COLLECTION=puppet6
69-
- TASK=beaker:centos-6-x64:acceptance[7.8.0]
53+
- TASK=beaker:amazonlinux-2-x64:acceptance[6.8.12]
7054
- env:
7155
- BEAKER_PUPPET_COLLECTION=puppet6
7256
- TASK=beaker:centos-7-x64:acceptance
7357
- env:
7458
- BEAKER_PUPPET_COLLECTION=puppet6
75-
- TASK=beaker:centos-7-x64:acceptance[7.8.0]
59+
- TASK=beaker:centos-7-x64:acceptance[6.8.12]
7660
- env:
7761
- BEAKER_PUPPET_COLLECTION=puppet6
7862
- TASK=beaker:centos-8-x64:acceptance
7963
- env:
8064
- BEAKER_PUPPET_COLLECTION=puppet6
81-
- TASK=beaker:centos-8-x64:acceptance[7.8.0]
82-
- env:
83-
- BEAKER_PUPPET_COLLECTION=puppet6
84-
- TASK=beaker:oracle-6-x64:acceptance
85-
- env:
86-
- BEAKER_PUPPET_COLLECTION=puppet6
87-
- TASK=beaker:oracle-6-x64:acceptance[7.8.0]
65+
- TASK=beaker:centos-8-x64:acceptance[6.8.12]
8866
- env:
8967
- BEAKER_PUPPET_COLLECTION=puppet6
9068
- TASK=beaker:oracle-7-x64:acceptance
9169
- env:
9270
- BEAKER_PUPPET_COLLECTION=puppet6
93-
- TASK=beaker:oracle-7-x64:acceptance[7.8.0]
71+
- TASK=beaker:oracle-7-x64:acceptance[6.8.12]
9472
- env:
9573
- BEAKER_PUPPET_COLLECTION=puppet6
9674
- TASK=beaker:debian-8-x64:acceptance
9775
- env:
9876
- BEAKER_PUPPET_COLLECTION=puppet6
99-
- TASK=beaker:debian-8-x64:acceptance[7.8.0]
77+
- TASK=beaker:debian-8-x64:acceptance[6.8.12]
10078
- env:
10179
- BEAKER_PUPPET_COLLECTION=puppet6
10280
- TASK=beaker:debian-9-x64:acceptance
10381
- env:
10482
- BEAKER_PUPPET_COLLECTION=puppet6
105-
- TASK=beaker:debian-9-x64:acceptance[7.8.0]
83+
- TASK=beaker:debian-9-x64:acceptance[6.8.12]
10684
- env:
10785
- BEAKER_PUPPET_COLLECTION=puppet6
10886
- TASK=beaker:debian-10-x64:acceptance
10987
- env:
11088
- BEAKER_PUPPET_COLLECTION=puppet6
111-
- TASK=beaker:debian-10-x64:acceptance[7.8.0]
89+
- TASK=beaker:debian-10-x64:acceptance[6.8.12]
11290
- env:
11391
- BEAKER_PUPPET_COLLECTION=puppet6
114-
- TASK=beaker:ubuntu-server-1404-x64:acceptance
92+
- TASK=beaker:ubuntu-server-1604-x64:acceptance
11593
- env:
11694
- BEAKER_PUPPET_COLLECTION=puppet6
117-
- TASK=beaker:ubuntu-server-1404-x64:acceptance[7.8.0]
95+
- TASK=beaker:ubuntu-server-1604-x64:acceptance[6.8.12]
11896
- env:
11997
- BEAKER_PUPPET_COLLECTION=puppet6
120-
- TASK=beaker:ubuntu-server-1604-x64:acceptance
98+
- TASK=beaker:ubuntu-server-1804-x64:acceptance
12199
- env:
122100
- BEAKER_PUPPET_COLLECTION=puppet6
123-
- TASK=beaker:ubuntu-server-1604-x64:acceptance[7.8.0]
101+
- TASK=beaker:ubuntu-server-1804-x64:acceptance[6.8.12]
124102
- env:
125103
- BEAKER_PUPPET_COLLECTION=puppet6
126-
- TASK=beaker:ubuntu-server-1804-x64:acceptance
104+
- TASK=beaker:ubuntu-server-2004-x64:acceptance
127105
- env:
128106
- BEAKER_PUPPET_COLLECTION=puppet6
129-
- TASK=beaker:ubuntu-server-1804-x64:acceptance[7.8.0]
130-
# - env:
131-
# - BEAKER_PUPPET_COLLECTION=puppet6
132-
# - TASK=beaker:ubuntu-server-2004-x64:acceptance
133-
# - env:
134-
# - BEAKER_PUPPET_COLLECTION=puppet6
135-
# - TASK=beaker:ubuntu-server-2004-x64:acceptance[7.8.0]
107+
- TASK=beaker:ubuntu-server-2004-x64:acceptance[6.8.12]
136108
- stage: snapshots
137-
env:
138-
- TASK=beaker:ubuntu-server-1404-x64:snapshot
139-
env:
140-
- OSS_PACKAGE=true
141-
- TASK=beaker:ubuntu-server-1404-x64:snapshot
142109
- env:
143110
- TASK=beaker:ubuntu-server-1604-x64:snapshot
144111
- env:
145112
- OSS_PACKAGE=true
146113
- TASK=beaker:ubuntu-server-1604-x64:snapshot
147-
- env:
148-
- TASK=beaker:centos-6-x64:snapshot
149-
- env:
150-
- OSS_PACKAGE=true
151-
- TASK=beaker:centos-6-x64:snapshot
152114
- env:
153115
- TASK=beaker:centos-7-x64:snapshot
154116
- env:

Rakefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ require_relative 'spec/spec_utilities'
1515
ENV['VAULT_APPROLE_ROLE_ID'] ||= '48adc137-3270-fc4a-ae65-1306919d4bb0'
1616
oss_package = ENV['OSS_PACKAGE'] and ENV['OSS_PACKAGE'] == 'true'
1717

18+
elasticsearch_default_version = '7.10.1'
19+
1820
# Workaround for certain rspec/beaker versions
1921
module TempFixForRakeLastComment
2022
def last_comment
@@ -137,7 +139,7 @@ beaker_node_sets.each do |node|
137139
"beaker:#{node}:acceptance", [:version, :filter] => [:spec_prep]
138140
) do |task, args|
139141
ENV['BEAKER_set'] = node
140-
args.with_defaults(:version => '6.8.6', :filter => nil)
142+
args.with_defaults(:version => elasticsearch_default_version, :filter => nil)
141143
task.pattern = 'spec/acceptance/tests/acceptance_spec.rb'
142144
task.rspec_opts = []
143145
task.rspec_opts << '--format documentation'

lib/facter/es_facts.rb

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
require 'yaml'
44

55
# Helper module to encapsulate custom fact injection
6-
# rubocop:disable Metrics/ModuleLength
76
module EsFacts
87
# Add a fact to the catalog of host facts
98
def self.add_fact(prefix, key, value)
@@ -15,9 +14,7 @@ def self.add_fact(prefix, key, value)
1514

1615
def self.ssl?(config)
1716
tls_keys = [
18-
'xpack.security.http.ssl.enabled',
19-
'shield.http.ssl',
20-
'searchguard.ssl.http.enabled'
17+
'xpack.security.http.ssl.enabled'
2118
]
2219

2320
tls_keys.any? { |key| (config.key? key) && (config[key] == true) }
@@ -28,13 +25,9 @@ def self.get_httpport(config)
2825
enabled = 'http.enabled'
2926
httpport = 'http.port'
3027

31-
if !config[enabled].nil? && config[enabled] == 'false'
32-
false
33-
elsif !config[httpport].nil?
34-
{ config[httpport] => ssl?(config) }
35-
else
36-
{ '9200' => ssl?(config) }
37-
end
28+
return false, false if !config[enabled].nil? && config[enabled] == 'false'
29+
return config[httpport], ssl?(config) unless config[httpport].nil?
30+
['9200', ssl?(config)]
3831
end
3932

4033
# Entrypoint for custom fact populator
@@ -46,7 +39,6 @@ def self.get_httpport(config)
4639
def self.run
4740
dir_prefix = '/etc/elasticsearch'
4841
# httpports is a hash of port_number => ssl?
49-
httpports = {}
5042
transportports = []
5143
http_bound_addresses = []
5244
transport_bound_addresses = []
@@ -56,34 +48,26 @@ def self.run
5648
# only when the directory exists we need to process the stuff
5749
return unless File.directory?(dir_prefix)
5850

59-
Dir.foreach(dir_prefix) do |dir|
60-
next if dir == '.'
61-
62-
if File.readable?("#{dir_prefix}/#{dir}/elasticsearch.yml")
63-
config_data = YAML.load_file("#{dir_prefix}/#{dir}/elasticsearch.yml")
64-
httpport = get_httpport(config_data)
65-
httpports.merge! httpport if httpport
66-
end
51+
if File.readable?("#{dir_prefix}/elasticsearch.yml")
52+
config_data = YAML.load_file("#{dir_prefix}/elasticsearch.yml")
53+
httpport, ssl = get_httpport(config_data)
6754
end
6855

6956
begin
70-
if httpports.keys.count > 0
71-
72-
add_fact('elasticsearch', 'ports', httpports.keys.join(','))
73-
74-
httpports.each_pair do |httpport, ssl|
75-
next if ssl
57+
add_fact('elasticsearch', 'port', httpport)
7658

77-
key_prefix = "elasticsearch_#{httpport}"
59+
unless ssl
60+
key_prefix = 'elasticsearch'
61+
# key_prefix = "elasticsearch_#{httpport}"
7862

79-
uri = URI("http://localhost:#{httpport}")
80-
http = Net::HTTP.new(uri.host, uri.port)
81-
http.read_timeout = 10
82-
http.open_timeout = 2
83-
response = http.get('/')
84-
json_data = JSON.parse(response.body)
85-
next if json_data['status'] && json_data['status'] != 200
63+
uri = URI("http://localhost:#{httpport}")
64+
http = Net::HTTP.new(uri.host, uri.port)
65+
http.read_timeout = 10
66+
http.open_timeout = 2
67+
response = http.get('/')
68+
json_data = JSON.parse(response.body)
8669

70+
if json_data['status'] && json_data['status'] == 200
8771
add_fact(key_prefix, 'name', json_data['name'])
8872
add_fact(key_prefix, 'version', json_data['version']['number'])
8973

@@ -122,12 +106,18 @@ def self.run
122106
transport_publish_addresses << nodes_data['transport']['publish_address'] unless nodes_data['transport']['publish_address'].nil?
123107
transportports << nodes_data['settings']['transport']['tcp']['port'] unless nodes_data['settings']['transport']['tcp'].nil? or nodes_data['settings']['transport']['tcp']['port'].nil?
124108

125-
node = { 'http_ports' => httpports.keys,
126-
'transport_ports' => transportports,
127-
'http_bound_addresses' => http_bound_addresses,
128-
'transport_bound_addresses' => transport_bound_addresses,
129-
'transport_publish_addresses' => transport_publish_addresses,
130-
json_data['name'] => { 'settings' => nodes_data['settings'], 'http' => nodes_data['http'], 'transport' => nodes_data['transport'] } }
109+
node = {
110+
'http_ports' => httpports.keys,
111+
'transport_ports' => transportports,
112+
'http_bound_addresses' => http_bound_addresses,
113+
'transport_bound_addresses' => transport_bound_addresses,
114+
'transport_publish_addresses' => transport_publish_addresses,
115+
json_data['name'] => {
116+
'settings' => nodes_data['settings'],
117+
'http' => nodes_data['http'],
118+
'transport' => nodes_data['transport']
119+
}
120+
}
131121
nodes.merge! node
132122
end
133123
end

lib/puppet/provider/elastic_plugin.rb

Lines changed: 11 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -68,35 +68,11 @@ def plugin_path
6868
@resource[:plugin_path] || Puppet_X::Elastic.plugin_name(@resource[:name])
6969
end
7070

71-
# Intelligently returns the correct installation arguments for version 1
72-
# version of Elasticsearch.
71+
# Intelligently returns the correct installation arguments for Elasticsearch.
7372
#
7473
# @return [Array<String>]
7574
# arguments to pass to the plugin installation utility
76-
def install1x
77-
if !@resource[:url].nil?
78-
[
79-
Puppet_X::Elastic.plugin_name(@resource[:name]),
80-
'--url',
81-
@resource[:url]
82-
]
83-
elsif !@resource[:source].nil?
84-
[
85-
Puppet_X::Elastic.plugin_name(@resource[:name]),
86-
'--url',
87-
"file://#{@resource[:source]}"
88-
]
89-
else
90-
[@resource[:name]]
91-
end
92-
end
93-
94-
# Intelligently returns the correct installation arguments for version 2
95-
# version of Elasticsearch.
96-
#
97-
# @return [Array<String>]
98-
# arguments to pass to the plugin installation utility
99-
def install2x
75+
def install_args
10076
if !@resource[:url].nil?
10177
[@resource[:url]]
10278
elsif !@resource[:source].nil?
@@ -122,13 +98,12 @@ def proxy_args(url)
12298
end
12399

124100
# Install this plugin on the host.
125-
# rubocop:disable Metrics/CyclomaticComplexity
126101
def create
127102
commands = []
128-
commands += proxy_args(@resource[:proxy]) if is2x? and @resource[:proxy]
103+
commands += proxy_args(@resource[:proxy]) if @resource[:proxy]
129104
commands << 'install'
130-
commands << '--batch' if batch_capable?
131-
commands += is1x? ? install1x : install2x
105+
commands << '--batch'
106+
commands += install_args
132107
debug("Commands: #{commands.inspect}")
133108

134109
retry_count = 3
@@ -145,7 +120,6 @@ def create
145120
raise "Failed to install plugin. Received error: #{e.inspect}"
146121
end
147122
end
148-
# rubocop:enable Metrics/CyclomaticComplexity
149123

150124
# Remove this plugin from the host.
151125
def destroy
@@ -154,26 +128,6 @@ def destroy
154128
end
155129
end
156130

157-
# Determine the installed version of Elasticsearch on this host.
158-
def es_version
159-
Puppet_X::Elastic::EsVersioning.version(
160-
resource[:elasticsearch_package_name], resource.catalog
161-
)
162-
end
163-
164-
def is1x?
165-
Puppet::Util::Package.versioncmp(es_version, '2.0.0') < 0
166-
end
167-
168-
def is2x?
169-
(Puppet::Util::Package.versioncmp(es_version, '2.0.0') >= 0) && \
170-
(Puppet::Util::Package.versioncmp(es_version, '3.0.0') < 0)
171-
end
172-
173-
def batch_capable?
174-
Puppet::Util::Package.versioncmp(es_version, '2.2.0') >= 0
175-
end
176-
177131
# Run a command wrapped in necessary env vars
178132
def with_environment(&block)
179133
env_vars = {
@@ -182,13 +136,12 @@ def with_environment(&block)
182136
}
183137
saved_vars = {}
184138

185-
unless @resource[:java_home].nil? or @resource[:java_home] == ''
186-
env_vars['JAVA_HOME'] = @resource[:java_home]
187-
end
188-
189-
if !is2x? and @resource[:proxy]
190-
env_vars['ES_JAVA_OPTS'] += proxy_args(@resource[:proxy])
191-
end
139+
# Use 'java_home' param if supplied, otherwise default to Elasticsearch shipped JDK
140+
env_vars['JAVA_HOME'] = if @resource[:java_home].nil? or @resource[:java_home] == ''
141+
"#{homedir}/jdk"
142+
else
143+
@resource[:java_home]
144+
end
192145

193146
env_vars['ES_JAVA_OPTS'] = env_vars['ES_JAVA_OPTS'].join(' ')
194147

0 commit comments

Comments
 (0)