Skip to content

Commit 5e7278a

Browse files
uberjew666Simon Hulme
authored andcommitted
elastic 7.x support
- Update JVM startup options - Add node name to log4j2.properties - Rename augeas resource to prevent dependency loop - Add boolean to enable/disable xpack and required features - Add self to contributors list - Add check for required certificate variables - Add version check for xpack related settings Maintains backwards compatibility - Resolve variable scope warnings - Update unit tests - Remove ubuntu 14.04 acceptance tests - Not supported https://www.elastic.co/support/matrix
1 parent 725afd6 commit 5e7278a

File tree

11 files changed

+118
-55
lines changed

11 files changed

+118
-55
lines changed

.travis.yml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
sudo: required
2-
group: deprecated-2017Q4
2+
group: deprecated-2017q4
33
services:
44
- docker
55
cache:
@@ -11,11 +11,6 @@ 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:
@@ -97,24 +92,13 @@ jobs:
9792
- TASK=beaker:debian-9-x64:acceptance[5.6.9]
9893
- env:
9994
- TASK=beaker:debian-9-x64:acceptance[2.4.6]
100-
- env:
101-
- TASK=beaker:ubuntu-server-1404-x64:acceptance
102-
- env:
103-
- TASK=beaker:ubuntu-server-1404-x64:acceptance[5.6.9]
104-
- env:
105-
- TASK=beaker:ubuntu-server-1404-x64:acceptance[2.4.6]
10695
- env:
10796
- TASK=beaker:ubuntu-server-1604-x64:acceptance
10897
- env:
10998
- TASK=beaker:ubuntu-server-1604-x64:acceptance[5.6.9]
11099
- env:
111100
- TASK=beaker:ubuntu-server-1604-x64:acceptance[2.4.6]
112101
- stage: snapshots
113-
env:
114-
- TASK=beaker:ubuntu-server-1404-x64:snapshot
115-
env:
116-
- OSS_PACKAGE=true
117-
- TASK=beaker:ubuntu-server-1404-x64:snapshot
118102
- env:
119103
- TASK=beaker:ubuntu-server-1604-x64:snapshot
120104
- env:

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ Matthias Baur (baurmatt)
3333
Gavin Williams (fatmcgav)
3434
Giedrius Statkevičius (GiedriusS)
3535
Jakub Pieńkowski (Jakski)
36+
Simon Hulme (uberjew666)

data/common.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,4 @@ elasticsearch::templates: {}
6565
elasticsearch::users: {}
6666
elasticsearch::validate_tls: true
6767
elasticsearch::version: false
68+
elasticsearch::xpack: false

lib/puppet/type/elasticsearch_keystore.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ def change_to_s(currentvalue, newvalue_raw)
5959
end
6060

6161
autorequire(:augeas) do
62-
"defaults_#{self[:name]}"
62+
"ks_defaults_#{self[:name]}"
6363
end
6464
end

manifests/init.pp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@
297297
# @param version
298298
# To set the specific version you want to install.
299299
#
300+
# @param xpack
301+
# Enable x-pack security. Requires ca_certificate, certificate and private key.
302+
#
300303
# @author Richard Pijnenburg <richard.pijnenburg@elasticsearch.com>
301304
# @author Tyler Langlois <tyler.langlois@elastic.co>
302305
#
@@ -371,6 +374,7 @@
371374
Hash $users,
372375
Boolean $validate_tls,
373376
Variant[String, Boolean] $version,
377+
Boolean $xpack,
374378
Boolean $restart_config_change = $restart_on_change,
375379
Boolean $restart_package_change = $restart_on_change,
376380
Boolean $restart_plugin_change = $restart_on_change,

manifests/instance.pp

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@
125125
# Source for the Shield system key. Valid values are any that are
126126
# supported for the file resource `source` parameter.
127127
#
128+
# @param xpack
129+
# Enable xpack security features. Requires ca_certificate, certificate and private_key.
130+
#
128131
# @author Richard Pijnenburg <richard.pijnenburg@elasticsearch.com>
129132
# @author Tyler Langlois <tyler.langlois@elastic.co>
130133
#
@@ -162,6 +165,7 @@
162165
Boolean $ssl = false,
163166
Elasticsearch::Status $status = $elasticsearch::status,
164167
Optional[String] $system_key = $elasticsearch::system_key,
168+
Boolean $xpack = $elasticsearch::xpack,
165169
) {
166170

167171
File {
@@ -273,6 +277,10 @@
273277
fail('keystore_password required')
274278
}
275279

280+
if (($ca_certificate == undef) or ($certificate == undef) or ($private_key == undef)) {
281+
fail('ca_certificate, certificate and private_key required')
282+
}
283+
276284
if ($keystore_path == undef) {
277285
$_keystore_path = "${configdir}/${security_plugin}/${name}.ks"
278286
} else {
@@ -287,11 +295,23 @@
287295
'shield.ssl.keystore.password' => $keystore_password,
288296
}
289297
} elsif $security_plugin == 'x-pack' {
290-
$tls_config = {
291-
'xpack.security.transport.ssl.enabled' => true,
292-
'xpack.security.http.ssl.enabled' => true,
293-
'xpack.ssl.keystore.path' => $_keystore_path,
294-
'xpack.ssl.keystore.password' => $keystore_password,
298+
if $elasticsearch::version.split(/\./)[0] == '7' {
299+
$tls_config = {
300+
'xpack.security.transport.ssl.enabled' => true,
301+
'xpack.security.transport.ssl.keystore.path' => $_keystore_path,
302+
'xpack.security.transport.ssl.keystore.password' => $keystore_password,
303+
'xpack.security.http.ssl.enabled' => true,
304+
'xpack.security.http.ssl.keystore.path' => $_keystore_path,
305+
'xpack.security.http.ssl.keystore.password' => $keystore_password,
306+
}
307+
}
308+
else {
309+
$tls_config = {
310+
'xpack.security.transport.ssl.enabled' => true,
311+
'xpack.security.http.ssl.enabled' => true,
312+
'xpack.ssl.keystore.path' => $_keystore_path,
313+
'xpack.ssl.keystore.password' => $keystore_password,
314+
}
295315
}
296316
}
297317

@@ -440,13 +460,51 @@
440460
}
441461
}
442462

463+
if $xpack {
464+
if (($ca_certificate == undef) or ($certificate == undef) or ($private_key == undef)) {
465+
fail('ca_certificate, certificate and private_key required')
466+
}
467+
468+
file { "${configdir}/ca_certificate.pem":
469+
ensure => 'file',
470+
source => "file://${ca_certificate}",
471+
owner => $elasticsearch::elasticsearch_user,
472+
group => undef,
473+
mode => '0640',
474+
}
475+
file { "${configdir}/certificate.pem":
476+
ensure => 'file',
477+
source => "file://${certificate}",
478+
owner => $elasticsearch::elasticsearch_user,
479+
group => undef,
480+
mode => '0640',
481+
}
482+
file { "${configdir}/private_key.key":
483+
ensure => 'file',
484+
source => "file://${private_key}",
485+
owner => $elasticsearch::elasticsearch_user,
486+
group => undef,
487+
mode => '0600',
488+
}
489+
490+
$xpack_config = {
491+
'xpack.security.enabled' => true,
492+
'xpack.security.transport.ssl.enabled' => true,
493+
'xpack.security.transport.ssl.verification_mode' => 'certificate',
494+
'xpack.security.transport.ssl.key' => "${configdir}/private_key.key",
495+
'xpack.security.transport.ssl.certificate' => "${configdir}/certificate.pem",
496+
'xpack.security.transport.ssl.certificate_authorities' => "${configdir}/ca_certificate.pem",
497+
}
498+
} else { $xpack_config = {} }
499+
443500
# build up new config
444501
$instance_conf = merge(
445502
$main_config,
446503
$instance_node_name,
447504
$instance_datadir_config,
448505
{ 'path.logs' => $logdir },
449506
$tls_config,
507+
$xpack_config,
450508
$instance_config
451509
)
452510

manifests/package.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@
182182

183183
exec { 'remove_plugin_dir':
184184
refreshonly => true,
185-
command => "rm -rf ${elasticsearch::_plugindir}",
185+
command => "rm -rf ${::elasticsearch::_plugindir}",
186186
}
187187

188188

manifests/plugin.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
plugin_dir => $::elasticsearch::_plugindir,
138138
plugin_path => $module_dir,
139139
}
140-
-> file { "${elasticsearch::_plugindir}/${_module_dir}":
140+
-> file { "${::elasticsearch::_plugindir}/${_module_dir}":
141141
ensure => $_file_ensure,
142142
mode => 'o+Xr',
143143
recurse => true,

spec/defines/005_elasticsearch_instance_spec.rb

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -790,30 +790,35 @@ class { 'elasticsearch':
790790
should contain_file('/etc/elasticsearch/es-instance/jvm.options')
791791
.with_content(%r{
792792
-Dfile.encoding=UTF-8.
793+
-Dio.netty.allocator.numDirectArenas=0.
793794
-Dio.netty.noKeySetOptimization=true.
794795
-Dio.netty.noUnsafe=true.
795796
-Dio.netty.recycler.maxCapacityPerThread=0.
796797
-Djava.awt.headless=true.
798+
-Djava.io.tmpdir=\${ES_TMPDIR}.
797799
-Djna.nosys=true.
798800
-Dlog4j.shutdownHookEnabled=false.
799801
-Dlog4j2.disable.jmx=true.
800802
-XX:\+AlwaysPreTouch.
801803
-XX:\+HeapDumpOnOutOfMemoryError.
802-
-XX:\+PrintGCDateStamps.
803-
-XX:\+PrintGCDetails.
804-
-XX:\+PrintTenuringDistribution.
805804
-XX:\+UseCMSInitiatingOccupancyOnly.
806-
-XX:\+UseConcMarkSweepGC.
807-
-XX:\+UseGCLogFileRotation.
808805
-XX:-OmitStackTraceInFastThrow.
809806
-XX:CMSInitiatingOccupancyFraction=75.
810-
-XX:GCLogFileSize=64m.
811-
-XX:NumberOfGCLogFiles=32.
812-
-Xloggc:\/var\/log\/elasticsearch\/es-instance\/gc.log.
813807
-Xms4g.
814808
-Xmx4g.
815809
-Xss1m.
816810
-server.
811+
8:-XX:\+UseConcMarkSweepGC.
812+
8:-XX:\+PrintGCApplicationStoppedTime.
813+
8:-XX:\+PrintGCDateStamps.
814+
8:-XX:\+PrintGCDetails.
815+
8:-XX:\+PrintTenuringDistribution.
816+
8:-XX:\+UseGCLogFileRotation.
817+
8:-XX:GCLogFileSize=64m.
818+
8:-XX:NumberOfGCLogFiles=5.
819+
8:-Xloggc:/var/log/elasticsearch/es-instance/gc.log.
820+
9-:-Djava.locale.providers=COMPAT.
821+
9-:-Xlog:gc\*,gc\+age=trace,safepoint:file=/var/log/elasticsearch/es-instance/gc.log:utctime,pid,tags:filecount=5,filesize=64m.
817822
}xm)
818823
end
819824
end
@@ -832,30 +837,35 @@ class { 'elasticsearch':
832837
should contain_file('/etc/elasticsearch/es-instance/jvm.options')
833838
.with_content(%r{
834839
-Dfile.encoding=UTF-8.
840+
-Dio.netty.allocator.numDirectArenas=0.
835841
-Dio.netty.noKeySetOptimization=true.
836842
-Dio.netty.noUnsafe=true.
837843
-Dio.netty.recycler.maxCapacityPerThread=0.
838844
-Djava.awt.headless=true.
845+
-Djava.io.tmpdir=\${ES_TMPDIR}.
839846
-Djna.nosys=true.
840847
-Dlog4j.shutdownHookEnabled=false.
841848
-Dlog4j2.disable.jmx=true.
842849
-XX:\+AlwaysPreTouch.
843850
-XX:\+HeapDumpOnOutOfMemoryError.
844-
-XX:\+PrintGCDateStamps.
845-
-XX:\+PrintGCDetails.
846-
-XX:\+PrintTenuringDistribution.
847851
-XX:\+UseCMSInitiatingOccupancyOnly.
848-
-XX:\+UseConcMarkSweepGC.
849-
-XX:\+UseGCLogFileRotation.
850852
-XX:-OmitStackTraceInFastThrow.
851853
-XX:CMSInitiatingOccupancyFraction=75.
852-
-XX:GCLogFileSize=64m.
853-
-XX:NumberOfGCLogFiles=32.
854-
-Xloggc:\/var\/log\/elasticsearch\/es-instance\/gc.log.
855854
-Xms8g.
856855
-Xmx8g.
857856
-Xss1m.
858857
-server.
858+
8:-XX:\+UseConcMarkSweepGC.
859+
8:-XX:\+PrintGCApplicationStoppedTime.
860+
8:-XX:\+PrintGCDateStamps.
861+
8:-XX:\+PrintGCDetails.
862+
8:-XX:\+PrintTenuringDistribution.
863+
8:-XX:\+UseGCLogFileRotation.
864+
8:-XX:GCLogFileSize=64m.
865+
8:-XX:NumberOfGCLogFiles=5.
866+
8:-Xloggc:/var/log/elasticsearch/es-instance/gc.log.
867+
9-:-Djava.locale.providers=COMPAT.
868+
9-:-Xlog:gc\*,gc\+age=trace,safepoint:file=/var/log/elasticsearch/es-instance/gc.log:utctime,pid,tags:filecount=5,filesize=64m.
859869
}xm)
860870
end
861871
end

templates/etc/elasticsearch/jvm.options.erb

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ end
99
defaults = {
1010
'-Xms' => '-Xms2g',
1111
'-Xmx' => '-Xmx2g',
12-
'UseConcMarkSweepGC' => '-XX:+UseConcMarkSweepGC',
12+
'UseConcMarkSweepGC' => '8:-XX:+UseConcMarkSweepGC',
1313
'CMSInitiatingOccupancyFraction=' => '-XX:CMSInitiatingOccupancyFraction=75',
1414
'UseCMSInitiatingOccupancyOnly' => '-XX:+UseCMSInitiatingOccupancyOnly',
1515
'AlwaysPreTouch' => '-XX:+AlwaysPreTouch',
@@ -22,16 +22,21 @@ defaults = {
2222
'-Dio.netty.noUnsafe' => '-Dio.netty.noUnsafe=true',
2323
'-Dio.netty.noKeySetOptimization' => '-Dio.netty.noKeySetOptimization=true',
2424
'-Dio.netty.recycler.maxCapacityPerThread' => '-Dio.netty.recycler.maxCapacityPerThread=0',
25+
'-Dio.netty.allocator.numDirectArenas' => '-Dio.netty.allocator.numDirectArenas=0',
2526
'-Dlog4j.shutdownHookEnabled' => '-Dlog4j.shutdownHookEnabled=false',
2627
'-Dlog4j2.disable.jmx' => '-Dlog4j2.disable.jmx=true',
28+
'-Djava.io.tmpdir' => '-Djava.io.tmpdir=${ES_TMPDIR}',
2729
'HeapDumpOnOutOfMemoryError' => '-XX:+HeapDumpOnOutOfMemoryError',
28-
'PrintGCDetails' => '-XX:+PrintGCDetails',
29-
'PrintGCDateStamps' => '-XX:+PrintGCDateStamps',
30-
'PrintTenuringDistribution' => '-XX:+PrintTenuringDistribution',
31-
'Xloggc' => "-Xloggc:#{@logdir}/gc.log",
32-
'UseGCLogFileRotation' => '-XX:+UseGCLogFileRotation',
33-
'NumberOfGCLogFiles' => '-XX:NumberOfGCLogFiles=32',
34-
'GCLogFileSize' => '-XX:GCLogFileSize=64m',
30+
'PrintGCDetails' => '8:-XX:+PrintGCDetails',
31+
'PrintGCDateStamps' => '8:-XX:+PrintGCDateStamps',
32+
'PrintTenuringDistribution' => '8:-XX:+PrintTenuringDistribution',
33+
'PrintGCApplicationStoppedTime' => '8:-XX:+PrintGCApplicationStoppedTime',
34+
'Xloggc' => "8:-Xloggc:#{@logdir}/gc.log",
35+
'UseGCLogFileRotation' => '8:-XX:+UseGCLogFileRotation',
36+
'NumberOfGCLogFiles' => '8:-XX:NumberOfGCLogFiles=5',
37+
'GCLogFileSize' => '8:-XX:GCLogFileSize=64m',
38+
'Xlog:gc' => "9-:-Xlog:gc*,gc+age=trace,safepoint:file=#{@logdir}/gc.log:utctime,pid,tags:filecount=5,filesize=64m",
39+
'Djava.locale.providers' => '9-:-Djava.locale.providers=COMPAT',
3540
}
3641
defaults.each {|k,v| set_default(@jvm_options, k, v)}
3742

templates/etc/elasticsearch/log4j2.properties.erb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ logger.action.level = debug
77
appender.console.type = Console
88
appender.console.name = console
99
appender.console.layout.type = PatternLayout
10-
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%m%n
10+
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] [%node_name]%marker%m%n
1111

1212
<%- if @file_rolling_type == 'file' -%>
1313
appender.fixed.type = File
1414
appender.fixed.name = fixed
1515
appender.fixed.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}.log
1616
appender.fixed.layout.type = PatternLayout
17-
appender.fixed.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%.-10000m%n
17+
appender.fixed.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] [%node_name]%marker%.-10000m%n
1818
<%- else -%>
1919
appender.rolling.type = RollingFile
2020
appender.rolling.name = rolling
2121
appender.rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}.log
2222
appender.rolling.layout.type = PatternLayout
23-
appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%.-10000m%n
23+
appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] [%node_name]%marker%.-10000m%n
2424
<%- if @file_rolling_type == 'dailyRollingFile' -%>
2525
appender.rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}-%d{yyyy-MM-dd}-%i.log.gz
2626
appender.rolling.policies.type = Policies
@@ -49,7 +49,7 @@ appender.deprecation_rolling.type = RollingFile
4949
appender.deprecation_rolling.name = deprecation_rolling
5050
appender.deprecation_rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_deprecation.log
5151
appender.deprecation_rolling.layout.type = PatternLayout
52-
appender.deprecation_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%.-10000m%n
52+
appender.deprecation_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] [%node_name]%marker%.-10000m%n
5353
appender.deprecation_rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_deprecation-%i.log.gz
5454
appender.deprecation_rolling.policies.type = Policies
5555
appender.deprecation_rolling.policies.size.type = SizeBasedTriggeringPolicy
@@ -70,7 +70,7 @@ appender.index_search_slowlog_rolling.type = RollingFile
7070
appender.index_search_slowlog_rolling.name = index_search_slowlog_rolling
7171
appender.index_search_slowlog_rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_search_slowlog.log
7272
appender.index_search_slowlog_rolling.layout.type = PatternLayout
73-
appender.index_search_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %marker%.-10000m%n
73+
appender.index_search_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] [%node_name]%marker%.-10000m%n
7474
appender.index_search_slowlog_rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_search_slowlog-%d{yyyy-MM-dd}.log
7575
appender.index_search_slowlog_rolling.policies.type = Policies
7676
appender.index_search_slowlog_rolling.policies.time.type = TimeBasedTriggeringPolicy
@@ -86,7 +86,7 @@ appender.index_indexing_slowlog_rolling.type = RollingFile
8686
appender.index_indexing_slowlog_rolling.name = index_indexing_slowlog_rolling
8787
appender.index_indexing_slowlog_rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_indexing_slowlog.log
8888
appender.index_indexing_slowlog_rolling.layout.type = PatternLayout
89-
appender.index_indexing_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %marker%.-10000m%n
89+
appender.index_indexing_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] [%node_name]%marker%.-10000m%n
9090
appender.index_indexing_slowlog_rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_indexing_slowlog-%d{yyyy-MM-dd}.log
9191
appender.index_indexing_slowlog_rolling.policies.type = Policies
9292
appender.index_indexing_slowlog_rolling.policies.time.type = TimeBasedTriggeringPolicy

0 commit comments

Comments
 (0)