Skip to content

Commit 618adbc

Browse files
committed
Add group and use jvm.options.d by default
1 parent ae40a0e commit 618adbc

File tree

3 files changed

+32
-18
lines changed

3 files changed

+32
-18
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ elasticsearch::slm_policy { 'policiyname':
446446

447447
#### Add a new SLM policy using a file
448448

449-
This will install and/or replace the SLM ploicy in Elasticsearch:
449+
This will install and/or replace the SLM policy in Elasticsearch:
450450

451451
```puppet
452452
elasticsearch::slm_policy { 'policyname':
@@ -495,7 +495,7 @@ elasticsearch::ilm_policy { 'policiyname':
495495

496496
#### Add a new ILM policy using a file
497497

498-
This will install and/or replace the ILM ploicy in Elasticsearch:
498+
This will install and/or replace the ILM policy in Elasticsearch:
499499

500500
```puppet
501501
elasticsearch::ilm_policy { 'policyname':
@@ -526,7 +526,7 @@ elasticsearch::ilm_policy { 'policyname':
526526
```
527527
#### Delete an ILM policy
528528

529-
This will install and/or replace the ILM ploicy in Elasticsearch:
529+
This will install and/or replace the ILM policy in Elasticsearch:
530530

531531
```puppet
532532
elasticsearch::ilm_policy { 'policyname':

manifests/config.pp

+23-14
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,29 @@
181181
mode => '0440',
182182
}
183183

184-
if ($elasticsearch::version != false and versioncmp($elasticsearch::version, '7.7.0') >= 0) {
184+
file { "${elasticsearch::configdir}/jvm.options":
185+
ensure => 'file',
186+
notify => $elasticsearch::_notify_service,
187+
require => Class['elasticsearch::package'],
188+
owner => 'root',
189+
group => $elasticsearch::elasticsearch_group,
190+
mode => '0640',
191+
}
192+
193+
if ($elasticsearch::version != false and versioncmp($elasticsearch::version, '7.7.0') < 0) {
194+
# Add any additional JVM options
195+
$elasticsearch::jvm_options.each |String $jvm_option| {
196+
$split_jvm_option = split($jvm_option, '=')
197+
file_line { "jvm_option_${jvm_option}":
198+
ensure => present,
199+
path => "${elasticsearch::configdir}/jvm.options",
200+
match => $split_jvm_option.length ? { 2 => "^${split_jvm_option[0]}=", default => undef, },
201+
line => $jvm_option,
202+
notify => $elasticsearch::_notify_service,
203+
}
204+
}
205+
}
206+
else {
185207
# https://www.elastic.co/guide/en/elasticsearch/reference/master/advanced-configuration.html#set-jvm-options
186208
# https://github.com/elastic/elasticsearch/pull/51882
187209
# >> "Do not modify the root jvm.options file. Use files in jvm.options.d/ instead."
@@ -197,19 +219,6 @@
197219
notify => $elasticsearch::_notify_service,
198220
}
199221
}
200-
else {
201-
# Add any additional JVM options
202-
$elasticsearch::jvm_options.each |String $jvm_option| {
203-
$split_jvm_option = split($jvm_option, '=')
204-
file_line { "jvm_option_${jvm_option}":
205-
ensure => present,
206-
path => "${elasticsearch::configdir}/jvm.options",
207-
match => $split_jvm_option.length ? { 2 => "^${split_jvm_option[0]}=", default => undef, },
208-
line => $jvm_option,
209-
notify => $elasticsearch::_notify_service,
210-
}
211-
}
212-
}
213222

214223
if $elasticsearch::system_key != undef {
215224
file { "${elasticsearch::configdir}/system_key":

spec/classes/000_elasticsearch_init_spec.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@
437437
end
438438
end
439439

440-
describe 'running a a different user' do
440+
describe 'running a different user' do
441441
let(:params) do
442442
default_params.merge(
443443
elasticsearch_user: 'myesuser',
@@ -464,6 +464,11 @@
464464
expect(subject).to contain_file('/var/lib/elasticsearch').
465465
with(owner: 'myesuser', group: 'myesgroup')
466466
}
467+
468+
it {
469+
expect(subject).to contain_file('/etc/elasticsearch/jvm.options').
470+
with(owner: 'root', group: 'myesgroup')
471+
}
467472
end
468473

469474
describe 'setting jvm_options before version 7.7.0' do

0 commit comments

Comments
 (0)