Skip to content

Commit

Permalink
Fix failing 'security_logging' tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin Williams committed Apr 29, 2020
1 parent 3bd4642 commit 67a0720
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 210 deletions.
46 changes: 21 additions & 25 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -165,27 +165,27 @@
$_tls_config = {}
}

# Logging file or hash
if ($elasticsearch::logging_file != undef) {
$_log4j_content = undef
} else {
if ($elasticsearch::logging_template != undef ) {
$_log4j_content = template($elasticsearch::logging_template)
} else {
$_log4j_content = template("${module_name}/etc/elasticsearch/log4j2.properties.erb")
}
$_logging_source = undef
}
file {
"${elasticsearch::configdir}/log4j2.properties":
ensure => file,
content => $_log4j_content,
source => $_logging_source,
mode => '0644',
notify => $elasticsearch::_notify_service,
require => Class['elasticsearch::package'],
before => Class['elasticsearch::service'],
}
# # Logging file or hash
# if ($elasticsearch::logging_file != undef) {
# $_log4j_content = undef
# } else {
# if ($elasticsearch::logging_template != undef ) {
# $_log4j_content = template($elasticsearch::logging_template)
# } else {
# $_log4j_content = template("${module_name}/etc/elasticsearch/log4j2.properties.erb")
# }
# $_logging_source = undef
# }
# file {
# "${elasticsearch::configdir}/log4j2.properties":
# ensure => file,
# content => $_log4j_content,
# source => $_logging_source,
# mode => '0644',
# notify => $elasticsearch::_notify_service,
# require => Class['elasticsearch::package'],
# before => Class['elasticsearch::service'],
# }

# Generate Elasticsearch config
$_es_config = merge(
Expand Down Expand Up @@ -244,10 +244,6 @@
backup => false,
}

file { "${elasticsearch::configdir}/jvm.options":
ensure => 'absent',
}

file { "${elasticsearch::defaults_location}/elasticsearch":
ensure => 'absent',
subscribe => Service['elasticsearch'],
Expand Down
34 changes: 17 additions & 17 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
# {package, "upgradeable"}[http://j.mp/xbxmNP] in the Puppet documentation).
#
# @param ca_certificate
# Path to the trusted CA certificate to add to this node's java keystore.
# Path to the trusted CA certificate to add to this node's Java keystore.
#
# @param certificate
# Path to the certificate for this node signed by the CA listed in
Expand Down Expand Up @@ -94,7 +94,7 @@
#
# @param deprecation_logging
# Wheter to enable deprecation logging. If enabled, deprecation logs will be
# saved to ${cluster.name}_deprecation.log in the elastic search log folder.
# saved to ${cluster.name}_deprecation.log in the Elasticsearch log folder.
#
# @param deprecation_logging_level
# Default deprecation logging level for Elasticsearch.
Expand Down Expand Up @@ -144,7 +144,7 @@
# Password to encrypt this node's Java keystore.
#
# @param keystore_path
# Custom path to the java keystore file. This parameter is optional.
# Custom path to the Java keystore file. This parameter is optional.
#
# @param license
# Optional Elasticsearch license in hash or string form.
Expand All @@ -153,11 +153,11 @@
# Directory that will be used for Elasticsearch logging.
#
# @param logging_config
# Representation of information to be included in the logging.yml file.
# Representation of information to be included in the log4j.properties file.
#
# @param logging_file
# Instead of a hash, you may supply a `puppet://` file source for the
# logging.yml file.
# log4j.properties file.
#
# @param logging_level
# Default logging level for Elasticsearch.
Expand Down Expand Up @@ -273,12 +273,12 @@
# Elasticsearch keystore file. If unset, the keystore is left unmanaged.
#
# @param security_logging_content
# File content for shield/x-pack logging configuration file (will be placed
# into logging.yml or log4j2.properties file as appropriate).
# File content for x-pack logging configuration file (will be placed
# into log4j2.properties file).
#
# @param security_logging_source
# File source for shield/x-pack logging configuration file (will be placed
# into logging.yml or log4j2.properties file as appropriate).
# File source for x-pack logging configuration file (will be placed
# into log4j2.properties).
#
# @param service_name
# Elasticsearch service name
Expand Down Expand Up @@ -466,14 +466,14 @@
contain elasticsearch::config
contain elasticsearch::service

create_resources('elasticsearch::index', $::elasticsearch::indices)
create_resources('elasticsearch::pipeline', $::elasticsearch::pipelines)
create_resources('elasticsearch::plugin', $::elasticsearch::plugins)
create_resources('elasticsearch::role', $::elasticsearch::roles)
create_resources('elasticsearch::script', $::elasticsearch::scripts)
create_resources('elasticsearch::snapshot_repository', $::elasticsearch::snapshot_repositories)
create_resources('elasticsearch::template', $::elasticsearch::templates)
create_resources('elasticsearch::user', $::elasticsearch::users)
create_resources('elasticsearch::index', $elasticsearch::indices)
create_resources('elasticsearch::pipeline', $elasticsearch::pipelines)
create_resources('elasticsearch::plugin', $elasticsearch::plugins)
create_resources('elasticsearch::role', $elasticsearch::roles)
create_resources('elasticsearch::script', $elasticsearch::scripts)
create_resources('elasticsearch::snapshot_repository', $elasticsearch::snapshot_repositories)
create_resources('elasticsearch::template', $elasticsearch::templates)
create_resources('elasticsearch::user', $elasticsearch::users)

if ($manage_repo == true) {
if ($repo_stage == false) {
Expand Down
2 changes: 1 addition & 1 deletion manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@

exec { 'remove_plugin_dir':
refreshonly => true,
command => "rm -rf ${::elasticsearch::_plugindir}",
command => "rm -rf ${elasticsearch::_plugindir}",
}


Expand Down
8 changes: 4 additions & 4 deletions manifests/plugin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#
define elasticsearch::plugin (
Enum['absent', 'present'] $ensure = 'present',
Stdlib::Absolutepath $configdir = $::elasticsearch::configdir,
Stdlib::Absolutepath $configdir = $elasticsearch::configdir,
Array[String] $java_opts = [],
Optional[Stdlib::Absolutepath] $java_home = undef,
Optional[String] $module_dir = undef,
Expand Down Expand Up @@ -127,17 +127,17 @@
source => $file_source,
url => $url,
proxy => $_proxy,
plugin_dir => $::elasticsearch::_plugindir,
plugin_dir => $elasticsearch::_plugindir,
plugin_path => $module_dir,
}
-> file { "${::elasticsearch::_plugindir}/${_module_dir}":
-> file { "${elasticsearch::_plugindir}/${_module_dir}":
ensure => $_file_ensure,
mode => 'o+Xr',
recurse => true,
before => $_file_before,
}

if $::elasticsearch::restart_plugin_change {
if $elasticsearch::restart_plugin_change {
Elasticsearch_plugin[$name] {
notify +> Service['elasticsearch'],
}
Expand Down
6 changes: 3 additions & 3 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@

#### Service management

if $::elasticsearch::ensure == 'present' {
if $elasticsearch::ensure == 'present' {

case $::elasticsearch::status {
case $elasticsearch::status {
# make sure service is currently running, start it on boot
'enabled': {
$_service_ensure = 'running'
Expand Down Expand Up @@ -78,7 +78,7 @@
$_service_enable = false
}

service { $::elasticsearch::service_name:
service { $elasticsearch::service_name:
ensure => $_service_ensure,
enable => $_service_enable,
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/service/systemd.pp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
# }
}

service { $::elasticsearch::service_name:
service { $elasticsearch::service_name:
ensure => $_service_ensure,
enable => $_service_enable,
provider => 'systemd',
Expand Down
6 changes: 5 additions & 1 deletion spec/acceptance/tests/acceptance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@

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

include_examples('plugin acceptance tests', es_config, v[:elasticsearch_plugins]) unless v[:elasticsearch_plugins].empty?
include_examples(
'plugin acceptance tests',
es_config,
v[:elasticsearch_plugins]
) unless v[:elasticsearch_plugins].empty?

include_examples('snapshot repository acceptance tests')

Expand Down
7 changes: 2 additions & 5 deletions spec/classes/001_hiera_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,14 @@
let(:facts) { facts.merge(:scenario => 'singleinstance') }

# TODO: Fix this
# it { should contain_augeas('defaults') }
it { should contain_augeas('init_defaults') }
it { should contain_file('/etc/elasticsearch/elasticsearch.yml') }
it { should contain_datacat('/etc/elasticsearch/elasticsearch.yml') }
it { should contain_datacat_fragment('main_config') }
it { should contain_service('elasticsearch').with(
:ensure => 'running',
:enable => true
) }

%w[elasticsearch.yml log4j2.properties].each do |file|
it { should contain_file("/etc/elasticsearch/#{file}") }
end
end # of config

describe 'pipelines' do
Expand Down
83 changes: 0 additions & 83 deletions spec/classes/002_elasticsearch_config_security_logging_spec.rb

This file was deleted.

3 changes: 1 addition & 2 deletions spec/classes/099_coverage_spec.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# TODO: Re-enable this test
# at_exit { RSpec::Puppet::Coverage.report! 100 }
at_exit { RSpec::Puppet::Coverage.report! 100 }
Loading

0 comments on commit 67a0720

Please sign in to comment.