Puppet Class: wazuh::opendistro

Defined in:
manifests/opendistro.pp

Overview

Wazuh App Copyright © 2021 Wazuh Inc. (License GPLv2) Setup for opendistro

Parameters:

  • opendistro_cluster_name (Any) (defaults to: 'es-wazuh')
  • opendistro_node_name (Any) (defaults to: 'node-01')
  • opendistro_node_master (Any) (defaults to: true)
  • opendistro_node_data (Any) (defaults to: true)
  • opendistro_node_ingest (Any) (defaults to: true)
  • opendistro_node_max_local_storage_nodes (Any) (defaults to: '1')
  • opendistro_service (Any) (defaults to: 'elasticsearch')
  • opendistro_package (Any) (defaults to: 'opendistroforelasticsearch')
  • opendistro_version (Any) (defaults to: '1.13.2')
  • opendistro_path_data (Any) (defaults to: '/var/lib/elasticsearch')
  • opendistro_path_logs (Any) (defaults to: '/var/log/elasticsearch')
  • opendistro_ip (Any) (defaults to: 'localhost')
  • opendistro_port (Any) (defaults to: '9200')
  • opendistro_discovery_option (Any) (defaults to: 'discovery.type: single-node')
  • opendistro_cluster_initial_master_nodes (Any) (defaults to: "#cluster.initial_master_nodes: ['node-01']")
  • jvm_options_memmory (Any) (defaults to: '1g')


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'manifests/opendistro.pp', line 3

class wazuh::opendistro (
  # Elasticsearch.yml configuration

  $opendistro_cluster_name = 'es-wazuh',
  $opendistro_node_name = 'node-01',
  $opendistro_node_master = true,
  $opendistro_node_data = true,
  $opendistro_node_ingest = true,
  $opendistro_node_max_local_storage_nodes = '1',
  $opendistro_service = 'elasticsearch',
  $opendistro_package = 'opendistroforelasticsearch',
  $opendistro_version = '1.13.2',

  $opendistro_path_data = '/var/lib/elasticsearch',
  $opendistro_path_logs = '/var/log/elasticsearch',


  $opendistro_ip = 'localhost',
  $opendistro_port = '9200',
  $opendistro_discovery_option = 'discovery.type: single-node',
  $opendistro_cluster_initial_master_nodes = "#cluster.initial_master_nodes: ['node-01']",

# JVM options
  $jvm_options_memmory = '1g',

){

  class {'wazuh::repo_opendistro':}


  if $::osfamily == 'Debian' {
    Class['wazuh::repo_opendistro'] -> Class['apt::update'] -> Package['opendistroforelasticsearch']
  } else {
    Class['wazuh::repo_opendistro'] -> Package['opendistroforelasticsearch']
  }

  # install package
  package { 'opendistroforelasticsearch':
    ensure => $opendistro_version,
    name   => $opendistro_package,
  }

  file { 'Configure elasticsearch.yml':
    owner   => 'elasticsearch',
    path    => '/etc/elasticsearch/elasticsearch.yml',
    group   => 'elasticsearch',
    mode    => '0644',
    notify  => Service[$opendistro_service], ## Restarts the service
    content => template('wazuh/opendistro_yml.erb'),
    require => Package[$opendistro_package],
  }

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

  service { 'elasticsearch':
    ensure  => running,
    enable  => true,
    require => Package[$opendistro_package],
  }

  exec { 'Insert line limits':
    path    => '/usr/bin:/bin/',
    command => "echo 'elasticsearch - nofile  65535\nelasticsearch - memlock unlimited' >> /etc/security/limits.conf",
    require => Package[$opendistro_package],

  }

  exec { 'Verify Elasticsearch folders owner':
    path    => '/usr/bin:/bin',
    command => "chown elasticsearch:elasticsearch -R /etc/elasticsearch\
             && chown elasticsearch:elasticsearch -R /usr/share/elasticsearch\
             && chown elasticsearch:elasticsearch -R /var/lib/elasticsearch",
    require => Package[$opendistro_package],

  }


}