Adoptable Cookbooks List

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Elasticsearch Chef Cookbook

Attributes

Please consult attributes/default.rb for a large list
of checksums for many different archives and package files of different
elasticsearch versions. Both recipes and resources/providers here use those
default values.

You may use %s in your URL and this cookbook will use sprintf/format to insert
the version parameter as a string into your download_url.

For example, this will pass a username 'foo' to elasticsearch_user and set a uid to 1234:
default['elasticsearch']['user']['username'] = 'foo'
default['elasticsearch']['user']['uid'] = '1234'

Recipes

Resources are the intended way to consume this cookbook, however we have
provided a single recipe that configures Elasticsearch by downloading an archive
containing a distribution of Elasticsearch, and extracting that into /usr/share.

See the attributes section above to for what defaults you can adjust.

default

The default recipe creates an elasticsearch user, group, package installation,
configuration files, and service with all of the default options.

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.

We are supporting whyrun mode in this cookbook, simply because we're using all builtin resources from core Chef, and these also already support whyrun. If you contribute to this cookbook, please be sure to maintain that or guard dangerous Ruby code with something like if !whyrun_mode? || nested_resource.whyrun_supported?.

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:

Resources that share the same resource name

Resources that share the same value for instance_name

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_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' # type of install
version '5.6.4'
action :install # could be :remove as well
end

elasticsearch_install 'my_es_installation' do
type 'tarball' # type of install
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 # could be :remove as well
end

elasticsearch_install 'my_es_installation' do
type 'tarball' # type of install
version '5.6.4'
action :install # could be :remove as well
end

elasticsearch_configure

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.

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.

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.

Breaking changes that were needed for v5.0.0 support (#497, #512, #424, #478, #503):
- We dropped the fancy logic for figuring out the requested version of Elasticsearch to be installed. You should pass it on the resource or in the recipe, but we no longer do a bunch of logic to figure out what you meant -- we favor being explicit now.
- We now start the service by default, instead of only :enable but not :start.
- Dropped gc_options parameter of elasticsearch_configure, and now have jvm.options. We've also dropped thread_stack_size and env_options, as they aren't used in the upstream packaging as defaults anymore.
- Install the tarball and package files into the same locations. There's no more /usr/local.
- Install types are now 'strings', not :symbols. node['elasticsearch'][<resource>][<param>] sets any elasticsearch::default recipe.