Handle advanced settings for Elasticsearch

These parameters are configured with default values if not provided:
* number_of_replicas
* minimum_master_nodes
* recover_after_time
* recover_after_nodes

Change-Id: I3f4c1135c61b209e6e7b6160142c147721306cf9
This commit is contained in:
Swann Croiset 2015-12-15 16:29:59 +01:00
parent 84a56c7de9
commit 9c3955a15f
3 changed files with 59 additions and 21 deletions

View File

@ -14,7 +14,7 @@
#
prepare_network_config(hiera('network_scheme', {}))
$mgmt_address = get_network_role_property('management', 'ipaddr')
$elasticsearch_kibana = hiera('elasticsearch_kibana')
$elasticsearch_kibana = hiera_hash('elasticsearch_kibana')
$network_metadata = hiera('network_metadata')
$es_nodes = get_nodes_hash_by_roles($network_metadata, ['elasticsearch_kibana'])
$es_address_map = get_node_to_ipaddr_map_by_network_role($es_nodes, 'management')
@ -55,24 +55,28 @@ class { 'elasticsearch':
# Start an instance of elasticsearch
elasticsearch::instance { $es_instance:
config => {
'threadpool.bulk.queue_size' => '1000',
'bootstrap.mlockall' => true,
'http.cors.allow-origin' => '/.*/',
'http.cors.enabled' => true,
'cluster.name' => $lma_logging_analytics::params::es_cluster_name,
'node.name' => "${::hostname}_${es_instance}",
'node.master' => true,
'node.data' => true,
'discovery.zen.ping.multicast' => {'enabled' => false},
'discovery.zen.ping.unicast.hosts' => $es_nodes_ips,
'http.bind_host' => $mgmt_address,
'transport.bind_host' => $mgmt_address,
'transport.publish_host' => $mgmt_address,
'threadpool.bulk.queue_size' => '1000',
'bootstrap.mlockall' => true,
'http.cors.allow-origin' => '/.*/',
'http.cors.enabled' => true,
'cluster.name' => $lma_logging_analytics::params::es_cluster_name,
'node.name' => "${::fqdn}_${es_instance}",
'node.master' => true,
'node.data' => true,
'discovery.zen.ping.multicast' => {'enabled' => false},
'discovery.zen.ping.unicast.hosts' => $es_nodes_ips,
'discovery.zen.minimum_master_nodes' => hiera('lma::elasticsearch::minimum_master_nodes'),
'gateway.recover_after_time' => hiera('lma::elasticsearch::recover_after_time'),
'gateway.recover_after_nodes' => hiera('lma::elasticsearch::recover_after_nodes'),
'http.bind_host' => $mgmt_address,
'transport.bind_host' => $mgmt_address,
'transport.publish_host' => $mgmt_address,
}
}
lma_logging_analytics::es_template { ['log', 'notification']:
number_of_replicas => 0 + $elasticsearch_kibana['number_of_replicas'],
number_of_replicas => hiera('lma::elasticsearch::number_of_replicas'),
require => Elasticsearch::Instance[$es_instance],
host => $mgmt_address,
}

View File

@ -12,10 +12,40 @@
# License for the specific language governing permissions and limitations
# under the License.
#
$hiera_dir = '/etc/hiera/override'
$plugin_name = 'elasticsearch_kibana'
$plugin_yaml = "${plugin_name}.yaml"
$corosync_roles = [$plugin_name]
$hiera_dir = '/etc/hiera/override'
$plugin_name = 'elasticsearch_kibana'
$plugin_yaml = "${plugin_name}.yaml"
$corosync_roles = [$plugin_name]
$elasticsearch_kibana = hiera_hash('elasticsearch_kibana')
$network_metadata = hiera('network_metadata')
$es_nodes = get_nodes_hash_by_roles($network_metadata, ['elasticsearch_kibana'])
$es_nodes_count = count($es_nodes)
if is_integer($elasticsearch_kibana['number_of_replicas']) and $elasticsearch_kibana['number_of_replicas'] < $es_nodes_count {
$number_of_replicas = 0 + $elasticsearch_kibana['number_of_replicas']
}else{
# Override the replication number otherwise this will lead to a stale cluster health
$number_of_replicas = $es_nodes_count - 1
notice("Set number_of_replicas to ${number_of_replicas}")
}
if is_integer($elasticsearch_kibana['minimum_master_nodes'] and $elasticsearch_kibana['minimum_master_nodes'] <= $es_nodes_count) {
$minimum_master_nodes = 0 + $elasticsearch_kibana['minimum_master_nodes']
} elsif $es_nodes_count > 2 {
$minimum_master_nodes = floor($es_nodes_count / 2 + 1)
}else{
$minimum_master_nodes = 1
}
notice("Set minimum_master_nodes to ${minimum_master_nodes}")
$recover_after_time = 0 + $elasticsearch_kibana['recover_after_time']
if is_integer($elasticsearch_kibana['recover_after_nodes']) and $elasticsearch_kibana['recover_after_nodes'] <= $es_nodes_count {
$recover_after_nodes = $elasticsearch_kibana['recover_after_nodes']
} else {
$recover_after_nodes = floor($es_nodes_count * 2 / 3)
notice("Set recover_after_nodes to ${recover_after_nodes}")
}
$calculated_content = inline_template('
corosync_roles:
@ -23,6 +53,11 @@ corosync_roles:
@corosync_roles.each do |crole|
%> - <%= crole %>
<% end -%>
lma::elasticsearch::number_of_replicas: <%= @number_of_replicas %>
lma::elasticsearch::minimum_master_nodes: <%= @minimum_master_nodes %>
lma::elasticsearch::recover_after_time: <%= @recover_after_time %>
lma::elasticsearch::recover_after_nodes: <%= @recover_after_nodes %>
')
file {$hiera_dir:

View File

@ -14,9 +14,8 @@
#
prepare_network_config(hiera('network_scheme', {}))
$mgmt_address = get_network_role_property('management', 'ipaddr')
$elasticsearch_kibana = hiera('elasticsearch_kibana')
class { 'lma_logging_analytics::kibana':
number_of_replicas => 0 + $elasticsearch_kibana['number_of_replicas'],
number_of_replicas => hiera('lma::elasticsearch::number_of_replicas'),
es_host => $mgmt_address,
}