• Stars
    star
    882
  • Rank 50,549 (Top 2 %)
  • Language
    Ruby
  • License
    Other
  • Created over 12 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Development repository for the elasticsearch cookbook

Elasticsearch Chef Cookbook

Cookbook Version

Please review the frequently asked questions and contributing guidelines before opening issues or submitting pull requests.

Looking for Elasticsearch 5.x or 6.x?

Please check out the previous 3.x.x releases of this cookbook. Please consider pinning your cookbook to '> 3.0' for support for Elasticsearch 6 and earlier, or '> 4.0' release for Elasticsearch 6 and beyond.

Resources

Notifications and Service Start/Restart

The resources provided in this cookbook do not automatically restart services when changes have occurred. They do start services by default when configuring a new service This has been done to protect you from accidental data loss and service outages, as nodes might restart simultaneously or may not restart at all when bad configuration values are supplied.

elasticsearch_service has a special service_actions parameter you can use to specify what state the underlying service should be in on each chef run (defaults to :enabled and :started). It will also pass through all of the standard service resource actions to the underlying service resource if you wish to notify it.

You must supply your desired notifications when using each resource if you want Chef to automatically restart services. Again, we don't recommend this unless you know what you're doing.

Resource names

Many of the resources provided in this cookbook need to share configuration values. For example, the elasticsearch_service resource needs to know the path to the configuration file(s) generated by elasticsearch_configure and the path to the actual ES binary installed by elasticsearch_install. And they both need to know the appropriate system user and group defined by elasticsearch_user.

Search order: In order to make this easy, all resources in this cookbook use the following search order to locate resources that apply to the same overall Elasticsearch setup:

  1. Resources that share the same resource name
  2. Resources that share the same value for instance_name
  3. Resources named default or resources named elasticsearch
    • This fails if both default and elasticsearch resources exist

Examples of more complicated resource names are left to the reader, but here we present a typical example that should work in most cases:

elasticsearch_user 'elasticsearch'
elasticsearch_install 'elasticsearch'
elasticsearch_configure 'elasticsearch'
elasticsearch_service 'elasticsearch'
elasticsearch_plugin 'x-pack'

elasticsearch_user

Actions: :create, :remove

Creates a user and group on the system for use by elasticsearch. Here is an example with many of the default options and default values (all options except a resource name may be omitted).

Examples:

elasticsearch_user 'elasticsearch'
elasticsearch_user 'elasticsearch' do
  username 'elasticsearch'
  groupname 'elasticsearch'
  shell '/bin/bash'
  comment 'Elasticsearch User'

  action :create
end

elasticsearch_install

Actions: :install, :remove

Downloads the elasticsearch software, and unpacks it on the system. There are currently three ways to install -- 'repository' (the default), which creates an apt or yum repo and installs from there, 'package', which downloads the appropriate package from elasticsearch.org and uses the package manager to install it, and 'tarball' which downloads a tarball from elasticsearch.org and unpacks it. This resource also comes with a :remove action which will remove the package or directory elasticsearch was unpacked into.

You may always specify a download_url and/or download_checksum, and you may include %s which will be replaced by the version parameter you supply.

Please be sure to consult the above attribute section as that controls how Elasticsearch version, download URL and checksum are determined if you omit them.

NOTE: The :remove action has not been implemented yet. Pull requests are very much welcome & encouraged, if you'd like to see this feature.

Examples:

elasticsearch_install 'elasticsearch'
elasticsearch_install 'my_es_installation' do
  type 'package'
  version '7.8.0'
  action :install
end
elasticsearch_install 'my_es_installation' do
  type 'tarball'
  dir '/usr/local' # where to install

  download_url "https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.7.2.tar.gz"
  # sha256
  download_checksum "6f81935e270c403681e120ec4395c28b2ddc87e659ff7784608b86beb5223dd2"

  action :install
end
elasticsearch_install 'my_es_installation' do
  type 'tarball'
  version '7.8.0'
  action :install # could be :remove as well
end
elasticsearch_install 'my_es_installation' do
  type 'package' # type of install
  download_url "https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.7.2.deb"
  # sha256
  download_checksum "791fb9f2131be2cf8c1f86ca35e0b912d7155a53f89c2df67467ca2105e77ec2"
  instance_name 'elasticsearch'
  action :install # could be :remove as well
end

elasticsearch_configure

Actions: :manage, :remove

Configures an elasticsearch instance; creates directories for configuration, logs, and data. Writes files log4j2.properties, elasticsearch.in.sh and elasticsearch.yml.

The main attribute for this resource is configuration, which is a hash of any elasticsearch configuration directives. The other important attribute is default_configuration -- this contains the minimal set of required defaults.

Note that these are both not a Chef mash, everything must be in a single level of keys and values. Any settings you pass in configuration will be merged into (and potentially overwrite) any default settings.

See the examples, as well as the attributes in the resource file, for more.

Examples:

With all defaults -

elasticsearch_configure 'elasticsearch'

With mostly defaults -

elasticsearch_configure 'elasticsearch' do
    allocated_memory '512m'
    configuration ({
      'cluster.name' => 'escluster',
      'node.name' => 'node01',
      'http.port' => 9201
    })
end

Very complicated -

elasticsearch_configure 'my_elasticsearch' do
  # if you override one of these, you probably want to override all
  path_home     "/opt/elasticsearch"
  path_conf     "/etc/opt/elasticsearch"
  path_data     "/var/opt/elasticsearch"
  path_logs     "/var/log/elasticsearch"
  path_pid      "/var/run/elasticsearch"
  path_plugins  "/opt/elasticsearch/plugins"
  path_bin      "/opt/elasticsearch/bin"

  # override logging parameters
  cookbook_log4j2_properties "my_wrapper_cookbook"
  template_log4j2_properties "my_log4j2.properties.erb"

  logging({:"action" => 'INFO'})

  allocated_memory '123m'

  jvm_options %w(
                -XX:+UseParNewGC
                -XX:+UseConcMarkSweepGC
                -XX:CMSInitiatingOccupancyFraction=75
                -XX:+UseCMSInitiatingOccupancyOnly
                -XX:+HeapDumpOnOutOfMemoryError
                -XX:+PrintGCDetails
              )

  configuration ({
    'node.name' => 'crazy'
  })

  action :manage
end

elasticsearch_service

Actions: :configure, :remove

Writes out a system service configuration of the appropriate type, and enables it to start on boot. You can override almost all of the relevant settings in such a way that you may run multiple instances. Most settings will be taken from a matching elasticsearch_config resource in the collection.

elasticsearch_service 'elasticsearch'

If you'd like to skip init scripts and systemd scripts, simply pass nil for the template file (init_source or systemd_source) and this cookbook will entirely skip trying to setup those scripts. Combined with changing the default service actions, this will have the same effect as action :nothing.

elasticsearch_plugin

Actions: :install, :remove

Installs or removes a plugin to a given elasticsearch instance and plugin directory. Please note that there is currently no way to upgrade an existing plugin using commandline tools, so we haven't exposed that feature here either. Furthermore, there isn't a way to determine if a plugin is compatible with ES or even what version it is. So once we install a plugin to a directory, we generally assume that is the desired one and we don't touch it further.

See #264 for more info. NB: You may encounter issues on certain distros with NSS 3.16.1 and OpenJDK 7.x.

Officially supported or commercial plugins require just the plugin name:

elasticsearch_plugin 'analysis-icu' do
  action :install
end
elasticsearch_plugin 'shield' do
  action :install
end

Plugins from GitHub require a URL of 'username/repository' or 'username/repository/version':

elasticsearch_plugin 'kopf' do
  url 'lmenezes/elasticsearch-kopf'
  action :install
end

elasticsearch_plugin 'kopf' do
  url 'lmenezes/elasticsearch-kopf/1.5.7'
  action :install
end

Plugins from Maven Central or Sonatype require 'groupId/artifactId/version':

elasticsearch_plugin 'mapper-attachments' do
  url 'org.elasticsearch/elasticsearch-mapper-attachments/2.6.0'
  action :install
end

Plugins can be installed from a custom URL or file location as follows:

elasticsearch_plugin 'mapper-attachments' do
  url 'http://some.domain.name//my-plugin-1.0.0.zip'
  action :install
end

elasticsearch_plugin 'mapper-attachments' do
  url 'file:/path/to/my-plugin-1.0.0.zip'
  action :install
end

The plugin resource respects the https_proxy or http_proxy (non-SSL) Chef settings unless explicitly disabled using chef_proxy false:

elasticsearch_plugin 'kopf' do
  url 'lmenezes/elasticsearch-kopf'
  chef_proxy false
  action :install
end

To run multiple instances per machine, an explicit plugin_dir location has to be provided:

elasticsearch_plugin 'x-pack' do
  plugin_dir '/usr/share/elasticsearch_foo/plugins'
end

If for some reason, you want to name the resource something else, you may provide the true plugin name using the plugin_name parameter:

elasticsearch_plugin 'xyzzy' do
  plugin_name 'kopf'
  url 'lmenezes/elasticsearch-kopf'
  action :install
end

License

This software is licensed under the Apache 2 license, quoted below.

    Copyright (c) 2015 Elasticsearch <https://www.elastic.co/>

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

More Repositories

1

docker

Development repository for the docker cookbook
Ruby
1,344
star
2

aws

Development repository for the aws cookbook
Ruby
594
star
3

nginx

Development repository for the nginx cookbook
Ruby
551
star
4

rvm

Development repository for the rvm cookbook
Ruby
516
star
5

php

Development repository for the php cookbook
HTML
433
star
6

jenkins

Development repository for the jenkins cookbook
Ruby
423
star
7

java

Development repository for the java cookbook
Ruby
397
star
8

postgresql

Development repository for the postgresql cookbook
Ruby
352
star
9

mysql

Development repository for the mysql cookbook
Ruby
335
star
10

ruby_rbenv

Development repository for the ruby_rbenv cookbook
Ruby
332
star
11

redisio

Development repository for the redisio cookbook
HTML
297
star
12

apache2

Development repository for the apache2 cookbook
Ruby
282
star
13

nodejs

Development repository for the nodejs cookbook
Ruby
227
star
14

apt

Development repository for the apt cookbook
Ruby
203
star
15

consul

Development repository for the consul cookbook
Ruby
190
star
16

haproxy

Development repository for the haproxy cookbook
Ruby
156
star
17

graphite

Development repository for the graphite cookbook
Ruby
154
star
18

homebrew

Development repository for the homebrew cookbook
Ruby
149
star
19

users

Development repository for the users cookbook
Ruby
138
star
20

nagios

Development repository for the nagios cookbook
Ruby
124
star
21

ruby_build

Development repository for the ruby_build cookbook
Ruby
123
star
22

git

Development repository for the git cookbook
Ruby
122
star
23

logrotate

Development repository for the logrotate cookbook
Ruby
122
star
24

percona

Development repository for the percona cookbook
Ruby
117
star
25

openssh

Development repository for the openssh cookbook
Ruby
114
star
26

powershell

Development repository for the powershell cookbook
Ruby
110
star
27

postfix

Development repository for the postfix cookbook
Ruby
103
star
28

tomcat

Development repository for the tomcat cookbook
Ruby
99
star
29

line

Development repository for the line cookbook
Ruby
98
star
30

openvpn

Development repository for the openvpn cookbook
Ruby
98
star
31

ark

Development repository for the ark cookbook
Ruby
98
star
32

firewall

Development repository for the firewall cookbook
Ruby
95
star
33

yum

Development repository for the yum cookbook
Ruby
95
star
34

kafka

Development repository for the kafka cookbook
Ruby
91
star
35

erlang

Development repository for the erlang cookbook
Ruby
88
star
36

sublimechef

A Sublime Text 2 Package for authoring Chef related files
84
star
37

iis

Development repository for the iis cookbook
Ruby
82
star
38

etcd

Development repository for the etcd cookbook
Ruby
80
star
39

cron

Development repository for the cron cookbook
Ruby
77
star
40

grafana

Development repository for the grafana cookbook
Ruby
76
star
41

sc-mongodb

Development repository for the sc-mongodb cookbook
Ruby
75
star
42

chef-splunk

Development repository for the chef-splunk cookbook
Ruby
75
star
43

certificate

Development repository for the certificate cookbook
Ruby
73
star
44

ntp

Development repository for the ntp cookbook
Ruby
68
star
45

rsyslog

Development repository for the rsyslog cookbook
Ruby
65
star
46

sql_server

Development repository for the sql_server cookbook
Ruby
63
star
47

windows_ad

Development repository for the windows_ad cookbook
Ruby
59
star
48

fail2ban

Development repository for the fail2ban cookbook
Ruby
58
star
49

selinux

Development repository for the selinux cookbook
Ruby
58
star
50

vagrant

Development repository for the vagrant cookbook
Ruby
57
star
51

varnish

Development repository for the varnish cookbook
Ruby
56
star
52

lvm

Development repository for the lvm cookbook
Ruby
56
star
53

perl

Development repository for the perl cookbook
Ruby
52
star
54

memcached

Development repository for the memcached cookbook
Ruby
50
star
55

golang

Development repository for the golang cookbook
Ruby
49
star
56

mariadb

Development repository for the mariadb cookbook
Ruby
47
star
57

hashicorp-vault

Development repository for the hashicorp-vault cookbook
Ruby
46
star
58

rundeck

Development repository for the rundeck cookbook
Ruby
46
star
59

ufw

Development repository for the ufw cookbook
Ruby
44
star
60

ossec

Development repository for the ossec cookbook
Ruby
43
star
61

confluence

Development repository for the confluence cookbook
Ruby
43
star
62

openldap

Development repository for the openldap cookbook
Ruby
42
star
63

nfs

Development repository for the nfs cookbook
Ruby
40
star
64

kubernetes

Development repository for the kubernetes cookbook
Ruby
39
star
65

vim

Development repository for the vim cookbook
Ruby
38
star
66

maven

Development repository for the maven cookbook
Ruby
36
star
67

bind

Development repository for the bind cookbook
Ruby
36
star
68

passenger_apache2

Development repository for the passenger_apache2 cookbook
Ruby
36
star
69

keepalived

Development repository for the keepalived cookbook
Ruby
33
star
70

aptly

Development repository for the aptly cookbook
Ruby
31
star
71

samba

Development repository for the samba cookbook
Ruby
30
star
72

resolver

Development repository for the resolver cookbook
Ruby
28
star
73

squid

Development repository for the squid cookbook
Ruby
28
star
74

freebsd

Development repository for the freebsd cookbook
Ruby
27
star
75

snort

Development repository for the snort cookbook
Ruby
27
star
76

pyenv

Development repository for the pyenv cookbook
Ruby
27
star
77

dhcp

Development repository for the dhcp cookbook
Ruby
27
star
78

nrpe

Development repository for the nrpe cookbook
Ruby
25
star
79

yum-epel

Development repository for the yum-epel cookbook
Ruby
24
star
80

rsync

Development repository for the rsync cookbook
Ruby
24
star
81

github

Development repository for the github cookbook
Ruby
24
star
82

filesystem

Development repository for the filesystem cookbook
Ruby
24
star
83

network_interfaces

Development repository for the network_interfaces cookbook
Ruby
24
star
84

djbdns

Development repository for the djbdns cookbook
Ruby
19
star
85

drbd

Development repository for the drbd cookbook
Ruby
19
star
86

dpkg_autostart

Development repository for the dpkg_autostart cookbook
Ruby
18
star
87

sssd_ldap

Development repository for the sssd_ldap cookbook
Ruby
18
star
88

packagecloud

Development repository for the packagecloud cookbook
Ruby
17
star
89

webpi

Development repository for the webpi cookbook
Ruby
17
star
90

gems

Development repository for the gems cookbook
Ruby
17
star
91

language-chef

Development repository for the language-chef plugin for the Atom text editor
JavaScript
17
star
92

elixir

Development repository for the elixir cookbook
Ruby
17
star
93

htpasswd

Development repository for the htpasswd cookbook
Ruby
15
star
94

stunnel

Development repository for the stunnel cookbook
Ruby
14
star
95

apparmor

Development repository for the apparmor cookbook
Ruby
14
star
96

transmission

Development repository for the transmission cookbook
Ruby
14
star
97

smartmontools

Development repository for the smartmontools cookbook
HTML
13
star
98

gpg

Development repository for the gpg cookbook
Ruby
12
star
99

wix

Development repository for the wix cookbook
Ruby
12
star
100

tftp

Development repository for the tftp cookbook
Ruby
11
star