Skip to content

Commit adc4cac

Browse files
committed
Merge branch 'master' into hiera-plugindir-call
2 parents 50a0dbd + 835e679 commit adc4cac

File tree

8 files changed

+61
-22
lines changed

8 files changed

+61
-22
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Puppet 4.10.0 is the new minimum required version of Puppet.
99
#### Fixes
1010
* The Elasticsearch log directory is no longer recursively managed to avoid stomping on the user/mode settings that Elasticsearch prefers.
1111
* Package management on apt-based systems no longer encounters dependency errors when `manage_repo => false`.
12+
* Plugin configuration files are now more well-supported by respecting subdirectory copy recursion. See `elasticsearch::configdir_recurselimit` for more information.
1213
* An error related to elasticsearch_roles and `yield` errors has been fixed
1314
* Correctly permit instances to be set to `absent` without errors.
1415
* Resolved an issue arising from the use of `hiera()` in Hiera yaml data files.

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ Jose Luis Ledesma (sp-joseluis-ledesma)
3232
Matthias Baur (baurmatt)
3333
Gavin Williams (fatmcgav)
3434
Giedrius Statkevičius (GiedriusS)
35+
Jakub Pieńkowski (Jakski)

data/common.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ elasticsearch::api_timeout: 10
1111
elasticsearch::autoupgrade: false
1212
elasticsearch::config: {}
1313
elasticsearch::configdir: /etc/elasticsearch
14+
elasticsearch::configdir_recurselimit: 2
1415
elasticsearch::daily_rolling_date_pattern: |
1516
"'.'yyyy-MM-dd"
1617
elasticsearch::datadir_instance_directories: true

lib/facter/es_facts.rb

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
require 'yaml'
44

55
# Helper module to encapsulate custom fact injection
6+
# rubocop:disable Metrics/ModuleLength
67
module EsFacts
78
# Add a fact to the catalog of host facts
89
def self.add_fact(prefix, key, value)
@@ -19,18 +20,18 @@ def self.ssl?(config)
1920
'searchguard.ssl.http.enabled'
2021
]
2122

22-
tls_keys.any? { |key| config.key? key and config[key] == true }
23+
tls_keys.any? { |key| (config.key? key) && (config[key] == true) }
2324
end
2425

25-
# Helper to determine the instance port number
26-
def self.get_port(config)
26+
# Helper to determine the instance http.port number
27+
def self.get_httpport(config)
2728
enabled = 'http.enabled'
28-
port = 'http.port'
29+
httpport = 'http.port'
2930

30-
if not config[enabled].nil? and config[enabled] == 'false'
31+
if !config[enabled].nil? && config[enabled] == 'false'
3132
false
32-
elsif not config[port].nil?
33-
{ config[port] => ssl?(config) }
33+
elsif !config[httpport].nil?
34+
{ config[httpport] => ssl?(config) }
3435
else
3536
{ '9200' => ssl?(config) }
3637
end
@@ -44,8 +45,13 @@ def self.get_port(config)
4445
# rubocop:disable Metrics/PerceivedComplexity
4546
def self.run
4647
dir_prefix = '/etc/elasticsearch'
47-
# Ports is a hash of port_number => ssl?
48-
ports = {}
48+
# httpports is a hash of port_number => ssl?
49+
httpports = {}
50+
transportports = []
51+
http_bound_addresses = []
52+
transport_bound_addresses = []
53+
transport_publish_addresses = []
54+
nodes = {}
4955

5056
# only when the directory exists we need to process the stuff
5157
return unless File.directory?(dir_prefix)
@@ -55,22 +61,22 @@ def self.run
5561

5662
if File.readable?("#{dir_prefix}/#{dir}/elasticsearch.yml")
5763
config_data = YAML.load_file("#{dir_prefix}/#{dir}/elasticsearch.yml")
58-
port = get_port(config_data)
59-
next unless port
60-
ports.merge! port
64+
httpport = get_httpport(config_data)
65+
httpports.merge! httpport if httpport
6166
end
6267
end
6368

6469
begin
65-
if ports.keys.count > 0
70+
if httpports.keys.count > 0
6671

67-
add_fact('elasticsearch', 'ports', ports.keys.join(','))
68-
ports.each_pair do |port, ssl|
72+
add_fact('elasticsearch', 'ports', httpports.keys.join(','))
73+
74+
httpports.each_pair do |httpport, ssl|
6975
next if ssl
7076

71-
key_prefix = "elasticsearch_#{port}"
77+
key_prefix = "elasticsearch_#{httpport}"
7278

73-
uri = URI("http://localhost:#{port}")
79+
uri = URI("http://localhost:#{httpport}")
7480
http = Net::HTTP.new(uri.host, uri.port)
7581
http.read_timeout = 10
7682
http.open_timeout = 2
@@ -81,7 +87,7 @@ def self.run
8187
add_fact(key_prefix, 'name', json_data['name'])
8288
add_fact(key_prefix, 'version', json_data['version']['number'])
8389

84-
uri2 = URI("http://localhost:#{port}/_nodes/#{json_data['name']}")
90+
uri2 = URI("http://localhost:#{httpport}/_nodes/#{json_data['name']}")
8591
http2 = Net::HTTP.new(uri2.host, uri2.port)
8692
http2.read_timeout = 10
8793
http2.open_timeout = 2
@@ -110,10 +116,29 @@ def self.run
110116
end
111117
end
112118
add_fact(key_prefix, 'plugins', plugin_names.join(','))
119+
120+
nodes_data['http']['bound_address'].each { |i| http_bound_addresses << i }
121+
nodes_data['transport']['bound_address'].each { |i| transport_bound_addresses << i }
122+
transport_publish_addresses << nodes_data['transport']['publish_address'] unless nodes_data['transport']['publish_address'].nil?
123+
transportports << nodes_data['settings']['transport']['tcp']['port'] unless nodes_data['settings']['transport']['tcp'].nil? or nodes_data['settings']['transport']['tcp']['port'].nil?
124+
125+
node = { 'http_ports' => httpports.keys,
126+
'transport_ports' => transportports,
127+
'http_bound_addresses' => http_bound_addresses,
128+
'transport_bound_addresses' => transport_bound_addresses,
129+
'transport_publish_addresses' => transport_publish_addresses,
130+
json_data['name'] => { 'settings' => nodes_data['settings'], 'http' => nodes_data['http'], 'transport' => nodes_data['transport'] } }
131+
nodes.merge! node
113132
end
114133
end
115134
rescue
116135
end
136+
Facter.add(:elasticsearch) do
137+
setcode do
138+
nodes
139+
end
140+
nodes unless nodes.empty?
141+
end
117142
end
118143
# rubocop:enable Metrics/CyclomaticComplexity
119144
# rubocop:enable Metrics/PerceivedComplexity

manifests/init.pp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@
6565
# Directory containing the elasticsearch configuration.
6666
# Use this setting if your packages deviate from the norm (`/etc/elasticsearch`)
6767
#
68+
# @param configdir_recurselimit
69+
# Dictates how deeply the file copy recursion logic should descend when
70+
# copying files from the `configdir` to instance `configdir`s.
71+
#
6872
# @param daily_rolling_date_pattern
6973
# File pattern for the file appender log when file_rolling_type is 'dailyRollingFile'.
7074
#
@@ -309,6 +313,7 @@
309313
Boolean $autoupgrade,
310314
Hash $config,
311315
Stdlib::Absolutepath $configdir,
316+
Integer $configdir_recurselimit,
312317
String $daily_rolling_date_pattern,
313318
Elasticsearch::Multipath $datadir,
314319
Boolean $datadir_instance_directories,
@@ -585,4 +590,8 @@
585590
-> Elasticsearch::Instance <| ensure == 'absent' |>
586591
Elasticsearch::Snapshot_repository <| |>
587592
-> Elasticsearch::Instance <| ensure == 'absent' |>
593+
594+
# Ensure scripts are installed before copying them to configuration directory
595+
Elasticsearch::Script <| |>
596+
-> File["${configdir}/scripts"]
588597
}

manifests/instance.pp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
# Path to directory containing the elasticsearch configuration.
2424
# Use this setting if your packages deviate from the norm (/etc/elasticsearch).
2525
#
26+
# @param configdir_recurselimit
27+
# Dictates how deeply the file copy recursion logic should descend when
28+
# copying files from the `elasticsearch::configdir` to instance `configdir`s.
29+
#
2630
# @param daily_rolling_date_pattern
2731
# File pattern for the file appender log when file_rolling_type is `dailyRollingFile`
2832
#
@@ -130,6 +134,7 @@
130134
Optional[Stdlib::Absolutepath] $certificate = undef,
131135
Optional[Hash] $config = undef,
132136
Stdlib::Absolutepath $configdir = "${elasticsearch::configdir}/${name}",
137+
Integer $configdir_recurselimit = $elasticsearch::configdir_recurselimit,
133138
String $daily_rolling_date_pattern = $elasticsearch::daily_rolling_date_pattern,
134139
Optional[Elasticsearch::Multipath] $datadir = undef,
135140
Boolean $datadir_instance_directories = $elasticsearch::datadir_instance_directories,
@@ -366,7 +371,7 @@
366371
"${elasticsearch::configdir}/log4j2.properties",
367372
],
368373
recurse => 'remote',
369-
recurselimit => 1,
374+
recurselimit => $configdir_recurselimit,
370375
source => $elasticsearch::configdir,
371376
purge => $elasticsearch::purge_configdir,
372377
force => $elasticsearch::purge_configdir,

spec/defines/005_elasticsearch_instance_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,6 @@ class { 'elasticsearch':
799799
-Dlog4j2.disable.jmx=true.
800800
-XX:\+AlwaysPreTouch.
801801
-XX:\+HeapDumpOnOutOfMemoryError.
802-
-XX:\+PrintGCApplicationStoppedTime.
803802
-XX:\+PrintGCDateStamps.
804803
-XX:\+PrintGCDetails.
805804
-XX:\+PrintTenuringDistribution.
@@ -842,7 +841,6 @@ class { 'elasticsearch':
842841
-Dlog4j2.disable.jmx=true.
843842
-XX:\+AlwaysPreTouch.
844843
-XX:\+HeapDumpOnOutOfMemoryError.
845-
-XX:\+PrintGCApplicationStoppedTime.
846844
-XX:\+PrintGCDateStamps.
847845
-XX:\+PrintGCDetails.
848846
-XX:\+PrintTenuringDistribution.

templates/etc/elasticsearch/jvm.options.erb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ defaults = {
2828
'PrintGCDetails' => '-XX:+PrintGCDetails',
2929
'PrintGCDateStamps' => '-XX:+PrintGCDateStamps',
3030
'PrintTenuringDistribution' => '-XX:+PrintTenuringDistribution',
31-
'PrintGCApplicationStoppedTime' => '-XX:+PrintGCApplicationStoppedTime',
3231
'Xloggc' => "-Xloggc:#{@logdir}/gc.log",
3332
'UseGCLogFileRotation' => '-XX:+UseGCLogFileRotation',
3433
'NumberOfGCLogFiles' => '-XX:NumberOfGCLogFiles=32',

0 commit comments

Comments
 (0)