Skip to content

Commit 67a0720

Browse files
author
Gavin Williams
committed
Fix failing 'security_logging' tests
1 parent 3bd4642 commit 67a0720

15 files changed

+66
-210
lines changed

manifests/config.pp

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -165,27 +165,27 @@
165165
$_tls_config = {}
166166
}
167167

168-
# Logging file or hash
169-
if ($elasticsearch::logging_file != undef) {
170-
$_log4j_content = undef
171-
} else {
172-
if ($elasticsearch::logging_template != undef ) {
173-
$_log4j_content = template($elasticsearch::logging_template)
174-
} else {
175-
$_log4j_content = template("${module_name}/etc/elasticsearch/log4j2.properties.erb")
176-
}
177-
$_logging_source = undef
178-
}
179-
file {
180-
"${elasticsearch::configdir}/log4j2.properties":
181-
ensure => file,
182-
content => $_log4j_content,
183-
source => $_logging_source,
184-
mode => '0644',
185-
notify => $elasticsearch::_notify_service,
186-
require => Class['elasticsearch::package'],
187-
before => Class['elasticsearch::service'],
188-
}
168+
# # Logging file or hash
169+
# if ($elasticsearch::logging_file != undef) {
170+
# $_log4j_content = undef
171+
# } else {
172+
# if ($elasticsearch::logging_template != undef ) {
173+
# $_log4j_content = template($elasticsearch::logging_template)
174+
# } else {
175+
# $_log4j_content = template("${module_name}/etc/elasticsearch/log4j2.properties.erb")
176+
# }
177+
# $_logging_source = undef
178+
# }
179+
# file {
180+
# "${elasticsearch::configdir}/log4j2.properties":
181+
# ensure => file,
182+
# content => $_log4j_content,
183+
# source => $_logging_source,
184+
# mode => '0644',
185+
# notify => $elasticsearch::_notify_service,
186+
# require => Class['elasticsearch::package'],
187+
# before => Class['elasticsearch::service'],
188+
# }
189189

190190
# Generate Elasticsearch config
191191
$_es_config = merge(
@@ -244,10 +244,6 @@
244244
backup => false,
245245
}
246246

247-
file { "${elasticsearch::configdir}/jvm.options":
248-
ensure => 'absent',
249-
}
250-
251247
file { "${elasticsearch::defaults_location}/elasticsearch":
252248
ensure => 'absent',
253249
subscribe => Service['elasticsearch'],

manifests/init.pp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
# {package, "upgradeable"}[http://j.mp/xbxmNP] in the Puppet documentation).
6060
#
6161
# @param ca_certificate
62-
# Path to the trusted CA certificate to add to this node's java keystore.
62+
# Path to the trusted CA certificate to add to this node's Java keystore.
6363
#
6464
# @param certificate
6565
# Path to the certificate for this node signed by the CA listed in
@@ -94,7 +94,7 @@
9494
#
9595
# @param deprecation_logging
9696
# Wheter to enable deprecation logging. If enabled, deprecation logs will be
97-
# saved to ${cluster.name}_deprecation.log in the elastic search log folder.
97+
# saved to ${cluster.name}_deprecation.log in the Elasticsearch log folder.
9898
#
9999
# @param deprecation_logging_level
100100
# Default deprecation logging level for Elasticsearch.
@@ -144,7 +144,7 @@
144144
# Password to encrypt this node's Java keystore.
145145
#
146146
# @param keystore_path
147-
# Custom path to the java keystore file. This parameter is optional.
147+
# Custom path to the Java keystore file. This parameter is optional.
148148
#
149149
# @param license
150150
# Optional Elasticsearch license in hash or string form.
@@ -153,11 +153,11 @@
153153
# Directory that will be used for Elasticsearch logging.
154154
#
155155
# @param logging_config
156-
# Representation of information to be included in the logging.yml file.
156+
# Representation of information to be included in the log4j.properties file.
157157
#
158158
# @param logging_file
159159
# Instead of a hash, you may supply a `puppet://` file source for the
160-
# logging.yml file.
160+
# log4j.properties file.
161161
#
162162
# @param logging_level
163163
# Default logging level for Elasticsearch.
@@ -273,12 +273,12 @@
273273
# Elasticsearch keystore file. If unset, the keystore is left unmanaged.
274274
#
275275
# @param security_logging_content
276-
# File content for shield/x-pack logging configuration file (will be placed
277-
# into logging.yml or log4j2.properties file as appropriate).
276+
# File content for x-pack logging configuration file (will be placed
277+
# into log4j2.properties file).
278278
#
279279
# @param security_logging_source
280-
# File source for shield/x-pack logging configuration file (will be placed
281-
# into logging.yml or log4j2.properties file as appropriate).
280+
# File source for x-pack logging configuration file (will be placed
281+
# into log4j2.properties).
282282
#
283283
# @param service_name
284284
# Elasticsearch service name
@@ -466,14 +466,14 @@
466466
contain elasticsearch::config
467467
contain elasticsearch::service
468468

469-
create_resources('elasticsearch::index', $::elasticsearch::indices)
470-
create_resources('elasticsearch::pipeline', $::elasticsearch::pipelines)
471-
create_resources('elasticsearch::plugin', $::elasticsearch::plugins)
472-
create_resources('elasticsearch::role', $::elasticsearch::roles)
473-
create_resources('elasticsearch::script', $::elasticsearch::scripts)
474-
create_resources('elasticsearch::snapshot_repository', $::elasticsearch::snapshot_repositories)
475-
create_resources('elasticsearch::template', $::elasticsearch::templates)
476-
create_resources('elasticsearch::user', $::elasticsearch::users)
469+
create_resources('elasticsearch::index', $elasticsearch::indices)
470+
create_resources('elasticsearch::pipeline', $elasticsearch::pipelines)
471+
create_resources('elasticsearch::plugin', $elasticsearch::plugins)
472+
create_resources('elasticsearch::role', $elasticsearch::roles)
473+
create_resources('elasticsearch::script', $elasticsearch::scripts)
474+
create_resources('elasticsearch::snapshot_repository', $elasticsearch::snapshot_repositories)
475+
create_resources('elasticsearch::template', $elasticsearch::templates)
476+
create_resources('elasticsearch::user', $elasticsearch::users)
477477

478478
if ($manage_repo == true) {
479479
if ($repo_stage == false) {

manifests/package.pp

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

182182
exec { 'remove_plugin_dir':
183183
refreshonly => true,
184-
command => "rm -rf ${::elasticsearch::_plugindir}",
184+
command => "rm -rf ${elasticsearch::_plugindir}",
185185
}
186186

187187

manifests/plugin.pp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
#
5858
define elasticsearch::plugin (
5959
Enum['absent', 'present'] $ensure = 'present',
60-
Stdlib::Absolutepath $configdir = $::elasticsearch::configdir,
60+
Stdlib::Absolutepath $configdir = $elasticsearch::configdir,
6161
Array[String] $java_opts = [],
6262
Optional[Stdlib::Absolutepath] $java_home = undef,
6363
Optional[String] $module_dir = undef,
@@ -127,17 +127,17 @@
127127
source => $file_source,
128128
url => $url,
129129
proxy => $_proxy,
130-
plugin_dir => $::elasticsearch::_plugindir,
130+
plugin_dir => $elasticsearch::_plugindir,
131131
plugin_path => $module_dir,
132132
}
133-
-> file { "${::elasticsearch::_plugindir}/${_module_dir}":
133+
-> file { "${elasticsearch::_plugindir}/${_module_dir}":
134134
ensure => $_file_ensure,
135135
mode => 'o+Xr',
136136
recurse => true,
137137
before => $_file_before,
138138
}
139139

140-
if $::elasticsearch::restart_plugin_change {
140+
if $elasticsearch::restart_plugin_change {
141141
Elasticsearch_plugin[$name] {
142142
notify +> Service['elasticsearch'],
143143
}

manifests/service.pp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545

4646
#### Service management
4747

48-
if $::elasticsearch::ensure == 'present' {
48+
if $elasticsearch::ensure == 'present' {
4949

50-
case $::elasticsearch::status {
50+
case $elasticsearch::status {
5151
# make sure service is currently running, start it on boot
5252
'enabled': {
5353
$_service_ensure = 'running'
@@ -78,7 +78,7 @@
7878
$_service_enable = false
7979
}
8080

81-
service { $::elasticsearch::service_name:
81+
service { $elasticsearch::service_name:
8282
ensure => $_service_ensure,
8383
enable => $_service_enable,
8484
}

manifests/service/systemd.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
# }
187187
}
188188

189-
service { $::elasticsearch::service_name:
189+
service { $elasticsearch::service_name:
190190
ensure => $_service_ensure,
191191
enable => $_service_enable,
192192
provider => 'systemd',

spec/acceptance/tests/acceptance_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@
6060

6161
include_examples('pipeline operations', es_config, v[:pipeline])
6262

63-
include_examples('plugin acceptance tests', es_config, v[:elasticsearch_plugins]) unless v[:elasticsearch_plugins].empty?
63+
include_examples(
64+
'plugin acceptance tests',
65+
es_config,
66+
v[:elasticsearch_plugins]
67+
) unless v[:elasticsearch_plugins].empty?
6468

6569
include_examples('snapshot repository acceptance tests')
6670

spec/classes/001_hiera_spec.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,14 @@
5050
let(:facts) { facts.merge(:scenario => 'singleinstance') }
5151

5252
# TODO: Fix this
53-
# it { should contain_augeas('defaults') }
53+
it { should contain_augeas('init_defaults') }
54+
it { should contain_file('/etc/elasticsearch/elasticsearch.yml') }
5455
it { should contain_datacat('/etc/elasticsearch/elasticsearch.yml') }
5556
it { should contain_datacat_fragment('main_config') }
5657
it { should contain_service('elasticsearch').with(
5758
:ensure => 'running',
5859
:enable => true
5960
) }
60-
61-
%w[elasticsearch.yml log4j2.properties].each do |file|
62-
it { should contain_file("/etc/elasticsearch/#{file}") }
63-
end
6461
end # of config
6562

6663
describe 'pipelines' do

spec/classes/002_elasticsearch_config_security_logging_spec.rb

Lines changed: 0 additions & 83 deletions
This file was deleted.

spec/classes/099_coverage_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# TODO: Re-enable this test
2-
# at_exit { RSpec::Puppet::Coverage.report! 100 }
1+
at_exit { RSpec::Puppet::Coverage.report! 100 }

0 commit comments

Comments
 (0)