Skip to content

Commit 41b3c14

Browse files
committed
Merge branch 'master' into java-dependency
2 parents b57a1cc + dfe3483 commit 41b3c14

File tree

10 files changed

+205
-85
lines changed

10 files changed

+205
-85
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
### Summary
44

55
#### Features
6+
* Added 'file_rolling_type' parameter to allow selecting file logging rotation type between "dailyRollingFile" or "rollingFile". Also added 'daily_rolling_date_pattern', 'rolling_file_max_backup_index' and 'rolling_file_max_file_size' for file rolling customization.
67

78
#### Bugfixes
89
* Permissions on the Elasticsearch plugin directory have been fixed to permit world read rights.
910
* The service systemd unit now `Wants=` a network target to fix bootup parallelization problems.
1011
* Recursively create the logdir for elasticsearch when creating multiple instances
1112
* Files and directories with root ownership now specify UID/GID 0 instead to improve compatability with *BSDs.
13+
* Elasticsearch Debian init file changed to avoid throwing errors when DATA_DIR, WORK_DIR and/or LOG_DIR were an empty variable.
1214

1315
#### Changes
1416
* The `api_ca_file` and `api_ca_path` parameters have been added to support custom CA bundles for API access.
17+
* Numerics in elasticsearch.yml will always be properly unquoted.
1518
* puppetlabs/java is now listed as a dependency in metadata.json to avoid unexpected installation problems.
1619

1720
#### Testing changes

CONTRIBUTORS

+1
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ Philip Wigg (philipwigg)
2828
Ian Bissett (bisscuitt)
2929
Fabian M. Krack (onibox)
3030
Rhommel Lamas (rhoml)
31+
Jose Luis Ledesma (sp-joseluis-ledesma)

manifests/init.pp

+94-60
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,27 @@
298298
# Value type is string
299299
# Default value: undef
300300
#
301+
# [*file_rolling_type*]
302+
# Configuration for the file appender rotation. It can be 'dailyRollingFile'
303+
# or 'rollingFile'. The first rotates by name, and the second one by size.
304+
# Value type is string
305+
# Default value: dailyRollingFile
306+
#
307+
# [*daily_rolling_date_pattern*]
308+
# File pattern for the file appender log when file_rolling_type is 'dailyRollingFile'
309+
# Value type is string
310+
# Default value: "'.'yyyy-MM-dd"
311+
#
312+
# [*rolling_file_max_backup_index*]
313+
# Max number of logs to store whern file_rolling_type is 'rollingFile'
314+
# Value type is integer
315+
# Default value: 1
316+
#
317+
# [*rolling_file_max_file_size*]
318+
# Max log file size when file_rolling_type is 'rollingFile'
319+
# Value type is string
320+
# Default value: 10MB
321+
#
301322
# The default values for the parameters are set in elasticsearch::params. Have
302323
# a look at the corresponding <tt>params.pp</tt> manifest file if you need more
303324
# technical information about them.
@@ -323,66 +344,70 @@
323344
# * Richard Pijnenburg <mailto:[email protected]>
324345
#
325346
class elasticsearch(
326-
$ensure = $elasticsearch::params::ensure,
327-
$status = $elasticsearch::params::status,
328-
$restart_on_change = $elasticsearch::params::restart_on_change,
329-
$restart_config_change = $elasticsearch::restart_on_change,
330-
$restart_package_change = $elasticsearch::restart_on_change,
331-
$restart_plugin_change = $elasticsearch::restart_on_change,
332-
$autoupgrade = $elasticsearch::params::autoupgrade,
333-
$version = false,
334-
$package_provider = 'package',
335-
$package_url = undef,
336-
$package_dir = $elasticsearch::params::package_dir,
337-
$package_name = $elasticsearch::params::package,
338-
$package_pin = true,
339-
$purge_package_dir = $elasticsearch::params::purge_package_dir,
340-
$package_dl_timeout = $elasticsearch::params::package_dl_timeout,
341-
$proxy_url = undef,
342-
$elasticsearch_user = $elasticsearch::params::elasticsearch_user,
343-
$elasticsearch_group = $elasticsearch::params::elasticsearch_group,
344-
$configdir = $elasticsearch::params::configdir,
345-
$purge_configdir = $elasticsearch::params::purge_configdir,
346-
$service_provider = 'init',
347-
$init_defaults = undef,
348-
$init_defaults_file = undef,
349-
$init_template = "${module_name}/etc/init.d/${elasticsearch::params::init_template}",
350-
$config = undef,
351-
$config_hiera_merge = false,
352-
$datadir = $elasticsearch::params::datadir,
353-
$logdir = $elasticsearch::params::logdir,
354-
$plugindir = $elasticsearch::params::plugindir,
355-
$java_install = false,
356-
$java_package = undef,
357-
$manage_repo = false,
358-
$repo_version = undef,
359-
$repo_priority = undef,
360-
$repo_key_id = '46095ACC8548582C1A2699A9D27D666CD88E42B4',
361-
$repo_key_source = 'http://packages.elastic.co/GPG-KEY-elasticsearch',
362-
$repo_proxy = undef,
363-
$logging_file = undef,
364-
$logging_config = undef,
365-
$logging_template = undef,
366-
$default_logging_level = $elasticsearch::params::default_logging_level,
367-
$repo_stage = false,
368-
$instances = undef,
369-
$instances_hiera_merge = false,
370-
$plugins = undef,
371-
$plugins_hiera_merge = false,
372-
$use_ssl = undef,
373-
$validate_ssl = undef,
374-
$ssl_user = undef,
375-
$ssl_password = undef,
376-
$api_protocol = 'http',
377-
$api_host = 'localhost',
378-
$api_port = 9200,
379-
$api_timeout = 10,
380-
$api_basic_auth_username = undef,
381-
$api_basic_auth_password = undef,
382-
$api_ca_file = undef,
383-
$api_ca_path = undef,
384-
$validate_tls = true,
385-
$system_key = undef,
347+
$ensure = $elasticsearch::params::ensure,
348+
$status = $elasticsearch::params::status,
349+
$restart_on_change = $elasticsearch::params::restart_on_change,
350+
$restart_config_change = $elasticsearch::restart_on_change,
351+
$restart_package_change = $elasticsearch::restart_on_change,
352+
$restart_plugin_change = $elasticsearch::restart_on_change,
353+
$autoupgrade = $elasticsearch::params::autoupgrade,
354+
$version = false,
355+
$package_provider = 'package',
356+
$package_url = undef,
357+
$package_dir = $elasticsearch::params::package_dir,
358+
$package_name = $elasticsearch::params::package,
359+
$package_pin = true,
360+
$purge_package_dir = $elasticsearch::params::purge_package_dir,
361+
$package_dl_timeout = $elasticsearch::params::package_dl_timeout,
362+
$proxy_url = undef,
363+
$elasticsearch_user = $elasticsearch::params::elasticsearch_user,
364+
$elasticsearch_group = $elasticsearch::params::elasticsearch_group,
365+
$configdir = $elasticsearch::params::configdir,
366+
$purge_configdir = $elasticsearch::params::purge_configdir,
367+
$service_provider = 'init',
368+
$init_defaults = undef,
369+
$init_defaults_file = undef,
370+
$init_template = "${module_name}/etc/init.d/${elasticsearch::params::init_template}",
371+
$config = undef,
372+
$config_hiera_merge = false,
373+
$datadir = $elasticsearch::params::datadir,
374+
$logdir = $elasticsearch::params::logdir,
375+
$plugindir = $elasticsearch::params::plugindir,
376+
$java_install = false,
377+
$java_package = undef,
378+
$manage_repo = false,
379+
$repo_version = undef,
380+
$repo_priority = undef,
381+
$repo_key_id = '46095ACC8548582C1A2699A9D27D666CD88E42B4',
382+
$repo_key_source = 'http://packages.elastic.co/GPG-KEY-elasticsearch',
383+
$repo_proxy = undef,
384+
$logging_file = undef,
385+
$logging_config = undef,
386+
$logging_template = undef,
387+
$default_logging_level = $elasticsearch::params::default_logging_level,
388+
$repo_stage = false,
389+
$instances = undef,
390+
$instances_hiera_merge = false,
391+
$plugins = undef,
392+
$plugins_hiera_merge = false,
393+
$use_ssl = undef,
394+
$validate_ssl = undef,
395+
$ssl_user = undef,
396+
$ssl_password = undef,
397+
$api_protocol = 'http',
398+
$api_host = 'localhost',
399+
$api_port = 9200,
400+
$api_timeout = 10,
401+
$api_basic_auth_username = undef,
402+
$api_basic_auth_password = undef,
403+
$api_ca_file = undef,
404+
$api_ca_path = undef,
405+
$validate_tls = true,
406+
$system_key = undef,
407+
$file_rolling_type = $elasticsearch::params::file_rolling_type,
408+
$daily_rolling_date_pattern = $elasticsearch::params::daily_rolling_date_pattern,
409+
$rolling_file_max_backup_index = $elasticsearch::params::rolling_file_max_backup_index,
410+
$rolling_file_max_file_size = $elasticsearch::params::rolling_file_max_file_size,
386411
) inherits elasticsearch::params {
387412

388413
anchor {'elasticsearch::begin': }
@@ -403,6 +428,15 @@
403428
fail("\"${status}\" is not a valid status parameter value")
404429
}
405430

431+
if ! ($file_rolling_type in [ 'dailyRollingFile', 'rollingFile']) {
432+
file("\"${file_rolling_type}\" is not a valid type")
433+
}
434+
435+
validate_integer($rolling_file_max_backup_index)
436+
validate_string($daily_rolling_date_pattern)
437+
validate_string($rolling_file_max_file_size)
438+
439+
406440
# restart on change
407441
validate_bool(
408442
$restart_on_change,

manifests/instance.pp

+46-21
Original file line numberDiff line numberDiff line change
@@ -111,33 +111,58 @@
111111
# Value type is string
112112
# Default value: undef
113113
#
114+
# [*file_rolling_type*]
115+
# Configuration for the file appender rotation. It can be 'dailyRollingFile'
116+
# or 'rollingFile'. The first rotates by name, and the second one by size.
117+
# Value type is string
118+
# Default value: dailyRollingFile
119+
#
120+
# [*daily_rolling_date_pattern*]
121+
# File pattern for the file appender log when file_rolling_type is 'dailyRollingFile'
122+
# Value type is string
123+
# Default value: "'.'yyyy-MM-dd"
124+
#
125+
# [*rolling_file_max_backup_index*]
126+
# Max number of logs to store whern file_rolling_type is 'rollingFile'
127+
# Value type is integer
128+
# Default value: 1
129+
#
130+
# [*rolling_file_max_file_size*]
131+
# Max log file size when file_rolling_type is 'rollingFile'
132+
# Value type is string
133+
# Default value: 10MB
134+
#
114135
# === Authors
115136
#
116137
# * Tyler Langlois <mailto:[email protected]>
117138
# * Richard Pijnenburg <mailto:[email protected]>
118139
#
119140
define elasticsearch::instance(
120-
$ensure = $elasticsearch::ensure,
121-
$status = $elasticsearch::status,
122-
$config = undef,
123-
$configdir = undef,
124-
$datadir = undef,
125-
$logdir = undef,
126-
$logging_file = undef,
127-
$logging_config = undef,
128-
$logging_template = undef,
129-
$logging_level = $elasticsearch::default_logging_level,
130-
$service_flags = undef,
131-
$init_defaults = undef,
132-
$init_defaults_file = undef,
133-
$init_template = $elasticsearch::init_template,
134-
$ssl = false,
135-
$ca_certificate = undef,
136-
$certificate = undef,
137-
$private_key = undef,
138-
$keystore_password = undef,
139-
$keystore_path = undef,
140-
$system_key = $elasticsearch::system_key,
141+
$ensure = $elasticsearch::ensure,
142+
$status = $elasticsearch::status,
143+
$config = undef,
144+
$configdir = undef,
145+
$datadir = undef,
146+
$logdir = undef,
147+
$logging_file = undef,
148+
$logging_config = undef,
149+
$logging_template = undef,
150+
$logging_level = $elasticsearch::default_logging_level,
151+
$service_flags = undef,
152+
$init_defaults = undef,
153+
$init_defaults_file = undef,
154+
$init_template = $elasticsearch::init_template,
155+
$ssl = false,
156+
$ca_certificate = undef,
157+
$certificate = undef,
158+
$private_key = undef,
159+
$keystore_password = undef,
160+
$keystore_path = undef,
161+
$system_key = $elasticsearch::system_key,
162+
$file_rolling_type = $elasticsearch::file_rolling_type,
163+
$daily_rolling_date_pattern = $elasticsearch::daily_rolling_date_pattern,
164+
$rolling_file_max_backup_index = $elasticsearch::rolling_file_max_backup_index,
165+
$rolling_file_max_file_size = $elasticsearch::rolling_file_max_file_size,
141166
) {
142167

143168
require elasticsearch::params

manifests/params.pp

+8
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@
6060
'index.indexing.slowlog' => 'TRACE, index_indexing_slow_log_file',
6161
}
6262

63+
$file_rolling_type = 'dailyRollingFile'
64+
65+
$daily_rolling_date_pattern = '"\'.\'yyyy-MM-dd"'
66+
67+
$rolling_file_max_backup_index = 1
68+
69+
$rolling_file_max_file_size ='10MB'
70+
6371
#### Internal module values
6472

6573
# User and Group for the files and user to run the service as.

spec/classes/000_elasticsearch_init_spec.rb

+25
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,31 @@
397397
it { should contain_file('/var/run/elasticsearch').with(:owner => 'myesuser') } if facts[:osfamily] == 'RedHat'
398398
end
399399

400+
context "rollingFile appender" do
401+
402+
let (:params) {
403+
default_params.merge({
404+
:file_rolling_type => 'rollingFile',
405+
:rolling_file_max_backup_index => 10,
406+
:rolling_file_max_file_size => '100MB',
407+
:instances => { 'test' => {} }
408+
})
409+
}
410+
411+
it { should contain_file('/etc/elasticsearch/test/logging.yml').with_content(/type: rollingFile/, /maxBackupIndex: 10/, /maxBackupIndex: 10/, /maxFileSize: 100MB/) }
412+
end
413+
414+
context "Default file appender" do
415+
416+
let (:params) {
417+
default_params.merge({
418+
:instances => { 'test' => {} }
419+
})
420+
}
421+
422+
it { should contain_file('/etc/elasticsearch/test/logging.yml').with_content(/type: dailyRollingFile/, /datePattern: "'.'yyyy-MM-dd"/) }
423+
end
424+
400425
end
401426

402427
end

spec/templates/001_elasticsearch.yml.erb_spec.rb

+12
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,16 @@ def unindent
7474
}.config))
7575
end
7676

77+
it 'should not quote numeric values' do
78+
harness.set(
79+
'@data', {
80+
'some.setting' => '10'
81+
}
82+
)
83+
84+
expect( YAML.load(harness.run) ).to eq( YAML.load(%q{
85+
some.setting: 10
86+
}.config))
87+
end
88+
7789
end

templates/etc/elasticsearch/elasticsearch.yml.erb

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
### MANAGED BY PUPPET ###
22
<%-
33
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),"..","..","..","lib"))
4+
require 'puppet_x/elastic/deep_to_i'
45
require 'puppet_x/elastic/hash'
56

67
@yml_string = ''
78

89
910

1011
# Sort Hash and transform it into yaml
11-
@yml_string += @data.extend(Puppet_X::Elastic::SortedHash).to_yaml
12+
@yml_string += Puppet_X::Elastic::deep_to_i(
13+
@data
14+
).extend(
15+
Puppet_X::Elastic::SortedHash
16+
).to_yaml
1217

1318
# Puppet < 4 uses ZAML, which has some deviations from Puppet 4 YAML
1419
# implementation

templates/etc/elasticsearch/logging.yml.erb

+7-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,14 @@ appender:
2828
conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"
2929

3030
file:
31-
type: dailyRollingFile
31+
type: <%= @file_rolling_type %>
3232
file: ${path.logs}/${cluster.name}.log
33-
datePattern: "'.'yyyy-MM-dd"
33+
<%- if @file_rolling_type == 'dailyRollingFile' -%>
34+
datePattern: <%= @daily_rolling_date_pattern %>
35+
<%- elsif @file_rolling_type == 'rollingFile' -%>
36+
maxBackupIndex: <%= @rolling_file_max_backup_index %>
37+
maxFileSize: <%= @rolling_file_max_file_size %>
38+
<%- end -%>
3439
layout:
3540
type: pattern
3641
conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"

templates/etc/init.d/elasticsearch.Debian.erb

+3-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ case "$1" in
149149
fi
150150

151151
# Prepare environment
152-
mkdir -p "$LOG_DIR" "$DATA_DIR" "$WORK_DIR" && chown "$ES_USER":"$ES_GROUP" "$LOG_DIR" "$DATA_DIR" "$WORK_DIR"
152+
for DIR in "$DATA_DIR" "$LOG_DIR" "$WORK_DIR"; do
153+
[ ! -z "$DIR" ] && mkdir -p "$DIR" && chown "$ES_USER":"$ES_GROUP" "$DIR"
154+
done
153155
touch "$PID_FILE" && chown "$ES_USER":"$ES_GROUP" "$PID_FILE"
154156

155157
if [ -n "$MAX_OPEN_FILES" ]; then

0 commit comments

Comments
 (0)