diff --git a/REFERENCE.md b/REFERENCE.md
index 3ec71e538..8f6b309ed 100644
--- a/REFERENCE.md
+++ b/REFERENCE.md
@@ -135,11 +135,14 @@ The following parameters are available in the `elasticsearch` class:
* [`logdir`](#-elasticsearch--logdir)
* [`logdir_mode`](#-elasticsearch--logdir_mode)
* [`logging_config`](#-elasticsearch--logging_config)
+* [`logging_content`](#-elasticsearch--logging_content)
* [`logging_file`](#-elasticsearch--logging_file)
* [`logging_level`](#-elasticsearch--logging_level)
+* [`logging_path`](#-elasticsearch--logging_path)
* [`logging_template`](#-elasticsearch--logging_template)
* [`manage_datadir`](#-elasticsearch--manage_datadir)
* [`manage_logdir`](#-elasticsearch--manage_logdir)
+* [`manage_logging`](#-elasticsearch--manage_logging)
* [`manage_repo`](#-elasticsearch--manage_repo)
* [`oss`](#-elasticsearch--oss)
* [`package_dir`](#-elasticsearch--package_dir)
@@ -451,6 +454,14 @@ Data type: `Hash`
Representation of information to be included in the log4j.properties file.
+##### `logging_content`
+
+Data type: `Optional[String]`
+
+Representation of content to be included in the log4j2.properties file.
+
+Default value: `undef`
+
##### `logging_file`
Data type: `Optional[String]`
@@ -464,6 +475,14 @@ Data type: `String`
Default logging level for Elasticsearch.
+##### `logging_path`
+
+Data type: `Stdlib::Absolutepath`
+
+Custom path to the logging file.
+
+Default value: `"${configdir}/log4j2.properties"`
+
##### `logging_template`
Data type: `Optional[String]`
@@ -483,6 +502,14 @@ Data type: `Boolean`
Enable logdir management (default true).
+##### `manage_logging`
+
+Data type: `Boolean`
+
+Enable logging (log4j) management (default false).
+
+Default value: `false`
+
##### `manage_repo`
Data type: `Boolean`
diff --git a/manifests/config.pp b/manifests/config.pp
index 9aeb2cb10..18c1a2ac6 100644
--- a/manifests/config.pp
+++ b/manifests/config.pp
@@ -163,6 +163,20 @@
# before => Class['elasticsearch::service'],
# }
+ # Logging file
+ if $elasticsearch::manage_logging and !empty($elasticsearch::logging_content) {
+ file { $elasticsearch::logging_path:
+ ensure => file,
+ content => $elasticsearch::logging_content,
+ group => $elasticsearch::elasticsearch_group,
+ owner => $elasticsearch::elasticsearch_user,
+ mode => '0644',
+ notify => $elasticsearch::_notify_service,
+ require => File[$elasticsearch::configdir],
+ before => Class['elasticsearch::service'],
+ }
+ }
+
# Generate Elasticsearch config
$data =
$elasticsearch::config + { 'path.data' => $elasticsearch::datadir } + { 'path.logs' => $elasticsearch::logdir } + $_tls_config
diff --git a/manifests/init.pp b/manifests/init.pp
index e97ad1217..9cff8a0f1 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -154,6 +154,9 @@
# @param logging_config
# Representation of information to be included in the log4j.properties file.
#
+# @param logging_content
+# Representation of content to be included in the log4j2.properties file.
+#
# @param logging_file
# Instead of a hash, you may supply a `puppet://` file source for the
# log4j.properties file.
@@ -161,6 +164,9 @@
# @param logging_level
# Default logging level for Elasticsearch.
#
+# @param logging_path
+# Custom path to the logging file.
+#
# @param logging_template
# Use a custom logging template - just supply the relative path, i.e.
# `$module/elasticsearch/logging.yml.erb`
@@ -171,6 +177,9 @@
# @param manage_logdir
# Enable logdir management (default true).
#
+# @param manage_logging
+# Enable logging (log4j) management (default false).
+#
# @param manage_repo
# Enable repo management by enabling official Elastic repositories.
#
@@ -430,6 +439,9 @@
String $default_logging_level = $logging_level,
Optional[String] $keystore_password = undef,
Optional[Stdlib::Absolutepath] $keystore_path = undef,
+ Optional[String] $logging_content = undef,
+ Stdlib::Absolutepath $logging_path = "${configdir}/log4j2.properties",
+ Boolean $manage_logging = false,
Optional[Stdlib::Absolutepath] $private_key = undef,
Enum['rsa','dsa','ec'] $private_key_type = 'rsa',
Boolean $restart_config_change = $restart_on_change,
diff --git a/spec/classes/000_elasticsearch_init_spec.rb b/spec/classes/000_elasticsearch_init_spec.rb
index 38e50426c..5dca4ad92 100644
--- a/spec/classes/000_elasticsearch_init_spec.rb
+++ b/spec/classes/000_elasticsearch_init_spec.rb
@@ -515,6 +515,59 @@
}
end
+ context 'When managing the logging file (with content)' do
+ let(:params) do
+ default_params.merge(
+ logging_content: '# Content',
+ manage_logging: true
+ )
+ end
+
+ it {
+ expect(subject).to contain_file('/etc/elasticsearch/log4j2.properties').
+ with(ensure: 'file', content: '# Content')
+ }
+ end
+
+ context 'When managing the logging file (with content and specific path)' do
+ let(:params) do
+ default_params.merge(
+ logging_content: '# Content',
+ logging_path: '/etc/elasticsearch/log4j.properties',
+ manage_logging: true
+ )
+ end
+
+ it {
+ expect(subject).to contain_file('/etc/elasticsearch/log4j.properties').
+ with(ensure: 'file', content: '# Content')
+ }
+ end
+
+ context 'When managing the logging file (with no content)' do
+ let(:params) do
+ default_params.merge(
+ manage_logging: true
+ )
+ end
+
+ it {
+ expect(subject).not_to contain_file('/etc/elasticsearch/log4j2.properties')
+ }
+ end
+
+ context 'When not managing the logging file' do
+ let(:params) do
+ default_params.merge(
+ manage_logging: false
+ )
+ end
+
+ it {
+ expect(subject).not_to contain_file('/etc/elasticsearch/log4j2.properties')
+ }
+ end
+
context 'with restart_on_change => true' do
let(:params) do
default_params.merge(