Skip to content

Commit

Permalink
Update elasticsearch files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose M committed Jun 7, 2019
1 parent 176eb26 commit 890fb88
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 25 deletions.
76 changes: 62 additions & 14 deletions manifests/elasticsearch.pp
Original file line number Diff line number Diff line change
@@ -1,25 +1,73 @@
class wazuh::elasticsearch (
# Elasticsearch.yml configuration

$elasticsearch_cluster_name = 'es-wazuh',
$elasticsearch_node_name = 'es-node-01',
$elasticsearch_node_master = 'true',
$elasticsearch_node_data = 'true',
$elasticsearch_node_ingest = 'true',
$elasticsearch_node_max_local_storage_nodes = '1',
$elasticsearch_service = 'elasticsearch',
$elasticsearch_package = 'elasticsearch',
$elasticsearch_version = '7.1.1',

$elasticsearch_path_data = "/var/lib/elasticsearch",
$elasticsearch_path_logs = "/var/log/elasticsearch",


$elasticsearch_ip = '172.17.0.101',
$elasticsearch_port = '9200',
$elasticsearch_discovery_option = 'discovery.type: single-node',
$elasticsearch_cluster_initial_master_nodes = "#cluster.initial_master_nodes: ['es-node-01']",

# JVM options
$jvm_options_memmory = "1g",

){

include "wazuh::repo_elastic"
class {"wazuh::repo_elastic":}
class {"wazuh::params_elastic":}

require "wazuh::params_elastic"
# install package
package { 'Installing elasticsearch...':
name => $elasticsearch_package,
ensure => $elasticsearch_version,
}

file { 'Configure elasticsearch.yml':
owner => 'root',
group => $wazuh::params_elastic::config_group,
mode => $wazuh::params_elastic::config_mode,
notify => Service[$wazuh::params_elastic::server_service],
require => Package[$wazuh::params_elastic::server_package];
'/etc/elasticsearch/elasticsearch.yml':
content => template("elasticsearch_yml.erb");
owner => 'elasticsearch',
path => '/etc/elasticsearch/elasticsearch.yml',
group => 'elasticsearch',
mode => '0644',
notify => Service[$elasticsearch_service], ## Restarts the service
content => template("wazuh/elasticsearch_yml.erb")
}

file { 'Configure jvm.options':
owner => 'elasticsearch',
path => '/etc/elasticsearch/jvm.options',
group => 'elasticsearch',
mode => '0660',
notify => Service[$elasticsearch_service], ## Restarts the service
content => template("wazuh/jvm_options.erb")
}

service { "elasticsearch":
ensure => running,
enable => true,
}

exec { 'Insert line limits.. ':
command => '<<-EOH
echo "elasticsearch - nofile 65535" >> /etc/security/limits.conf
echo "elasticsearch - memlock unlimited" >> /etc/security/limits.conf
EOH'
exec { 'Insert line limits':
command => "echo 'elasticsearch - nofile 65535\nelasticsearch - memlock unlimited' >> /etc/security/limits.conf",
provider => 'shell',
}

exec { 'Verify Elasticsearch folders owner':
command => "chown elasticsearch:elasticsearch -R /etc/elasticsearch \
&& chown elasticsearch:elasticsearch -R /usr/share/elasticsearch \
&& chown elasticsearch:elasticsearch -R /var/lib/elasticsearch",
provider => 'shell',
}


}
18 changes: 9 additions & 9 deletions templates/elasticsearch_yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@
#
# Use a descriptive name for your cluster:
#
<%= @clustername %>
cluster.name: <%= @elasticsearch_cluster_name %>
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
<%= @node_name %>
node.name: <%= @elasticsearch_node_name %>
#
# Add custom attributes to the node:
#
<%= @node_master %>
node.master: <%= @elasticsearch_node_master %>
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
<%= @path_data %>
path.data: <%= @elasticsearch_path_data %>
#
# Path to log files:
#
<%= @path_logs %>
path.logs: <%= @elasticsearch_path_logs %>
#
# ----------------------------------- Memory -----------------------------------
#
Expand All @@ -52,11 +52,11 @@
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
<%= @network_host %>
network.host: <%= @elasticsearch_ip %>
#
# Set a custom port for HTTP:
#
<%= @http_port %>
http.port: <%= @elasticsearch_port %>
#
# For more information, consult the network module documentation.
#
Expand All @@ -69,8 +69,8 @@
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
<%= @cluster_initial_master_nodes %>
<%= @discovery_option %>
<%= @elasticsearch_cluster_initial_master_nodes %>
<%= @elasticsearch_discovery_option %>
#
# For more information, consult the discovery and cluster formation module documentation.
#
Expand Down
4 changes: 2 additions & 2 deletions templates/jvm_options.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms<%= @memmory %>
-Xmx<%= @memmory %>
-Xms<%= @jvm_options_memmory %>
-Xmx<%= @jvm_options_memmory %>

################################################################
## Expert settings
Expand Down

0 comments on commit 890fb88

Please sign in to comment.