1 #Elasticsearch Puppet module
3 [![Build Status](https://travis-ci.org/elasticsearch/puppet-elasticsearch.png?branch=master)](https://travis-ci.org/elasticsearch/puppet-elasticsearch)
7 1. [Overview](#overview)
8 2. [Module description - What the module does and why it is useful](#module-description)
9 3. [Setup - The basics of getting started with Elasticsearch](#setup)
10 * [The module manages the following](#the-module-manages-the-following)
11 * [Requirements](#requirements)
12 4. [Usage - Configuration options and additional functionality](#usage)
13 5. [Advanced features - Extra information on advanced usage](#advanced-features)
14 6. [Limitations - OS compatibility, etc.](#limitations)
15 7. [Development - Guide for contributing to the module](#development)
16 8. [Support - When you need help with this module](#support)
22 This module manages Elasticsearch (http://www.elasticsearch.org/overview/elasticsearch/)
26 The elasticsearch module sets up Elasticsearch instances and can manage plugins and templates.
28 This module has been tested against ES 1.0 and up.
32 ###The module manages the following
34 * Elasticsearch repository files.
35 * Elasticsearch package.
36 * Elasticsearch configuration file.
37 * Elasticsearch service.
38 * Elasticsearch plugins.
39 * Elasticsearch templates.
43 * The [stdlib](https://forge.puppetlabs.com/puppetlabs/stdlib) Puppet library.
46 #### Repository management
47 When using the repository management you will need the following dependency modules:
49 * Debian/Ubuntu: [Puppetlabs/apt](http://forge.puppetlabs.com/puppetlabs/apt) Version 1.8.x or lower.
50 * OpenSuSE: [Darin/zypprepo](https://forge.puppetlabs.com/darin/zypprepo)
56 ####Install a specific version
59 class { 'elasticsearch':
64 Note: This will only work when using the repository.
66 ####Automatic upgrade of the software ( default set to false )
68 class { 'elasticsearch':
73 ####Removal/decommissioning
75 class { 'elasticsearch':
80 ####Install everything but disable service(s) afterwards
82 class { 'elasticsearch':
89 This module works with the concept of instances. For service to start you need to specify at least one instance.
93 elasticsearch::instance { 'es-01': }
96 This will set up its own data directory and set the node name to `$hostname-$instance_name`
100 Instance specific options can be given:
103 elasticsearch::instance { 'es-01':
104 config => { }, # Configuration hash
105 init_defaults => { }, # Init defaults hash
106 datadir => [ ], # Data directory
110 See [Advanced features](#advanced-features) for more information
114 Install [a variety of plugins](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-plugins.html#known-plugins). Note that `module_dir` is where the plugin will install itself to and must match that published by the plugin author; it is not where you would like to install it yourself.
116 ####From official repository
118 elasticsearch::plugin{'lmenezes/elasticsearch-kopf':
119 module_dir => 'kopf',
120 instances => 'instance_name'
125 elasticsearch::plugin{ 'elasticsearch-jetty':
126 module_dir => 'jetty',
127 url => 'https://oss-es-plugins.s3.amazonaws.com/elasticsearch-jetty/elasticsearch-jetty-1.2.1.zip',
128 instances => 'instance_name'
134 You can also use a proxy if required by setting the `proxy_host` and `proxy_port` options:
136 elasticsearch::plugin { 'lmenezes/elasticsearch-kopf',
137 module_dir => 'kopf',
138 instances => 'instance_name',
139 proxy_host => 'proxy.host.com',
144 #####Plugin name could be:
145 * `elasticsearch/plugin/version` for official elasticsearch plugins (download from download.elasticsearch.org)
146 * `groupId/artifactId/version` for community plugins (download from maven central or oss sonatype)
147 * `username/repository` for site plugins (download from github master)
149 ####Upgrading plugins
150 When you specify a certain plugin version, you can upgrade that plugin by specifying the new version.
153 elasticsearch::plugin { 'elasticsearch/elasticsearch-cloud-aws/2.1.1':
154 module_dir => 'cloud-aws',
158 And to upgrade, you would simply change it to
161 elasticsearch::plugin { 'elasticsearch/elasticsearch-cloud-aws/2.4.1':
162 module_dir => 'cloud-aws',
166 Please note that this does not work when you specify 'latest' as a version number.
170 Install [scripts](http://www.elastic.co/guide/en/elasticsearch/reference/1.x/modules-scripting.html) to be used by Elasticsearch.
171 These scripts are shared accross all defined instances on the same host.
174 elasticsearch::script { 'myscript':
176 source => 'puppet:///path/to/my/script.groovy'
182 #### Add a new template using a file
184 This will install and/or replace the template in Elasticsearch:
187 elasticsearch::template { 'templatename':
188 file => 'puppet:///path/to/template.json'
192 #### Add a new template using content
194 This will install and/or replace the template in Elasticsearch:
197 elasticsearch::template { 'templatename':
198 content => '{"template":"*","settings":{"number_of_replicas":0}}'
202 #### Delete a template
205 elasticsearch::template { 'templatename':
212 By default it uses localhost:9200 as host. you can change this with the `host` and `port` variables
215 elasticsearch::template { 'templatename':
216 host => $::ipaddress,
221 ###Bindings / Clients
223 Install a variety of [clients/bindings](http://www.elasticsearch.org/guide/en/elasticsearch/client/community/current/clients.html):
228 elasticsearch::python { 'rawes': }
233 elasticsearch::ruby { 'elasticsearch': }
236 ###Connection Validator
238 This module offers a way to make sure an instance has been started and is up and running before
239 doing a next action. This is done via the use of the `es_instance_conn_validator` resource.
241 es_instance_conn_validator { 'myinstance' :
242 server => 'es.example.com',
247 A common use would be for example :
251 require => Es_Instance_Conn_Validator['myinstance'],
255 ###Package installation
257 There are 2 different ways of installing the software
261 This option allows you to use an existing repository for package installation.
262 The `repo_version` corresponds with the major version of Elasticsearch.
265 class { 'elasticsearch':
267 repo_version => '1.4',
271 ####Remote package source
273 When a repository is not available or preferred you can install the packages from a remote source:
277 class { 'elasticsearch':
278 package_url => 'https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.2.deb'
284 class { 'elasticsearch':
285 package_url => 'puppet:///path/to/elasticsearch-1.4.2.deb'
291 class { 'elasticsearch':
292 package_url => 'file:/path/to/elasticsearch-1.4.2.deb'
298 Most sites will manage Java separately; however, this module can attempt to install Java as well.
299 This is done by using the [puppetlabs-java](https://forge.puppetlabs.com/puppetlabs/java) module.
302 class { 'elasticsearch':
307 Specify a particular Java package/version to be installed:
310 class { 'elasticsearch':
311 java_install => true,
312 java_package => 'packagename'
316 ###Service management
318 Currently only the basic SysV-style [init](https://en.wikipedia.org/wiki/Init) and [Systemd](http://en.wikipedia.org/wiki/Systemd) service providers are supported, but other systems could be implemented as necessary (pull requests welcome).
323 The *defaults* file (`/etc/defaults/elasticsearch` or `/etc/sysconfig/elasticsearch`) for the Elasticsearch service can be populated as necessary. This can either be a static file resource or a simple key value-style [hash](http://docs.puppetlabs.com/puppet/latest/reference/lang_datatypes.html#hashes) object, the latter being particularly well-suited to pulling out of a data source such as Hiera.
327 class { 'elasticsearch':
328 init_defaults_file => 'puppet:///path/to/defaults'
331 #####hash representation
334 'ES_USER' => 'elasticsearch',
335 'ES_GROUP' => 'elasticsearch',
338 class { 'elasticsearch':
339 init_defaults => $config_hash
343 Note: `init_defaults` hash can be passed to the main class and to the instance.
347 ###Package version pinning
349 The module supports pinning the package version to avoid accidental upgrades that are not done by Puppet.
350 To enable this feature:
353 class { 'elasticsearch':
359 In this example we pin the package version to 1.5.2.
364 There are 4 different ways of setting data directories for Elasticsearch.
365 In every case the required configuration options are placed in the `elasticsearch.yml` file.
370 `/usr/share/elasticsearch/data/$instance_name`
372 Which provides a data directory per instance.
375 ####Single global data directory
378 class { 'elasticsearch':
379 datadir => '/var/lib/elasticsearch-data'
382 Creates the following for each instance:
384 `/var/lib/elasticsearch-data/$instance_name`
386 ####Multiple Global data directories
389 class { 'elasticsearch':
390 datadir => [ '/var/lib/es-data1', '/var/lib/es-data2']
393 Creates the following for each instance:
394 `/var/lib/es-data1/$instance_name`
396 `/var/lib/es-data2/$instance_name`
399 ####Single instance data directory
402 class { 'elasticsearch': }
404 elasticsearch::instance { 'es-01':
405 datadir => '/var/lib/es-data-es01'
408 Creates the following for this instance:
409 `/var/lib/es-data-es01`
411 ####Multiple instance data directories
414 class { 'elasticsearch': }
416 elasticsearch::instance { 'es-01':
417 datadir => ['/var/lib/es-data1-es01', '/var/lib/es-data2-es01']
420 Creates the following for this instance:
421 `/var/lib/es-data1-es01`
423 `/var/lib/es-data2-es01`
426 ###Main and instance configurations
428 The `config` option in both the main class and the instances can be configured to work together.
430 The options in the `instance` config hash will merged with the ones from the main class and override any duplicates.
435 class { 'elasticsearch':
436 config => { 'cluster.name' => 'clustername' }
439 elasticsearch::instance { 'es-01':
440 config => { 'node.name' => 'nodename' }
442 elasticsearch::instance { 'es-02':
443 config => { 'node.name' => 'nodename2' }
448 This example merges the `cluster.name` together with the `node.name` option.
452 When duplicate options are provided, the option in the instance config overrides the ones from the main class.
455 class { 'elasticsearch':
456 config => { 'cluster.name' => 'clustername' }
459 elasticsearch::instance { 'es-01':
460 config => { 'node.name' => 'nodename', 'cluster.name' => 'otherclustername' }
463 elasticsearch::instance { 'es-02':
464 config => { 'node.name' => 'nodename2' }
468 This will set the cluster name to `otherclustername` for the instance `es-01` but will keep it to `clustername` for instance `es-02`
470 ####Configuration writeup
472 The `config` hash can be written in 2 different ways:
474 ##### Full hash writeup
476 Instead of writing the full hash representation:
478 class { 'elasticsearch':
481 'name' => 'ClusterName',
485 'attributes' => 'rack'
493 ##### Short hash writeup
495 class { 'elasticsearch':
498 'name' => 'ClusterName',
499 'routing.allocation.awareness.attributes' => 'rack'
508 This module has been built on and tested against Puppet 3.2 and higher.
510 The module has been tested on:
514 * Ubuntu 12.04, 14.04
517 Other distro's that have been reported to work:
523 Testing on other platforms has been light and cannot be guaranteed.
530 Need help? Join us in [#elasticsearch](https://webchat.freenode.net?channels=%23elasticsearch) on Freenode IRC or subscribe to the [elasticsearch@googlegroups.com](https://groups.google.com/forum/#!forum/elasticsearch) mailing list.