Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

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.

Select Badges

Select Supported Platforms

Select Status


apache_zookeeper (22) Versions 0.5.0

Installs/Configures Apache Zookeeper

cookbook 'apache_zookeeper', '= 0.5.0', :supermarket
cookbook 'apache_zookeeper', '= 0.5.0'
knife supermarket install apache_zookeeper
knife supermarket download apache_zookeeper
Quality 100%

Apache Zookeeper Cookbook

Cookbook Version

Installs and configures Apache Zookeeper.

View the Change Log to see what has changed.


  • CentOS
  • Ubuntu


Using the default attributes will setup a single Zookeeper server in standalone mode.

If you are wanting to setup Zookeeper in a multi-server cluster make sure to fill out the
node["zookeeper"]["servers"] like this,

node["zookeeper"]["servers"] = ["", "","]

The array should include a value per server and can be any of the following values,

  • FQDN - node['fqdn']
  • Host Name - node['hostname']
  • Machine Name - node['machinename']
  • Any network interface - node["network"]["interfaces"][..]
  • EC2 Host Name - node['ec2']['public_hostname']
  • EC2 IP Address - node['ec2']['public_ipv4']

This array is used to configure/calculate the server ids for each zookeeper.

You can also provide the server ids yourself by including values for the attributes
node["zookeeper"]["zoo.cfg"]["server.[ID]"]. If this is done you don't have to provide the
node["zookeeper"]["servers"] attribute.

What does the installation look like

By default the installation will look like,

zkCli | /usr/bin/zkCli  - The Zookeeper cli binary command
/opt/zookeeper/*        - All of Zookeeper's files (config, binaries, logs...)
/etc/init.d/zookeeper   - An init.d script to start/stop zookeeper. You can use service
                        zookeeper [start|stop|restart|status] instead

Unique Quorum and Leader Election Ports

It is possible to provide unique quorum and leader election ports in a few different ways.

node["zookeeper"]["servers"] = ["host1", "host2", "host3"]
node["zookeeper"]["follower_port"] = 2888
node["zookeeper"]["election_port"] = 3888


node["zookeeper"]["servers"] = ["host1:2888:3888", "host2:2888:3888", "host3:2888:3888"]


node["zookeeper"]["zoo.cfg"]["server.1"] = "host1:2888:3888"
node["zookeeper"]["zoo.cfg"]["server.2"] = "host2:2888:3888"
node["zookeeper"]["zoo.cfg"]["server.3"] = "host3:2888:3888"

Environment Variables

Should note that the and other various scripts provided by zookeeper taken in various environment variables to tweak
runtime settings. Here are some,

  • ZOO_LOG_DIR : Overwrites log4j zookeeper.log.file. Defaults to . if not set which is why we provide a default value for it to the node["zookeeper"]["log_directory"] value.
  • ZOO_LOG4J_PROP : Overwrites log4j zookeeper.root.logger. Defaults to 'INFO, CONSOLE' if not set which is why we provide a default value for it 'INFO,CONSOLE,ROLLINGFILE'
  • JMXDISABLE : Disables jmx. Defaults to enabling JMX. To disable set to any value
  • SERVER_JVMFLAGS : JVM flags for the server process


  • node["zookeeper"]["install_java"] : If you want to use the java cookbook to install java (default=true)
  • node["zookeeper"]["user"] : The user that owns the Zookeeper installation (default="zookeeper")
  • node["zookeeper"]["group"] : The group that owns the Zookeeper installation (default="zookeeper")
  • node["zookeeper"]["env_vars"] : The environment variables set for the zookeeper user (default={"ZOO_LOG_DIR" => node["zookeeper"]["log_directory"], "ZOO_LOG4J_PROP" => "'INFO, CONSOLE, ROLLINGFILE'"})
  • node["zookeeper"]["servers"] : The array of fqdn/hostnames/ips for the zookeeper servers in the cluster (default=[])
  • node["zookeeper"]["follower_port"] : The port used by zookeeper followers (default=2888)
  • node["zookeeper"]["election_port"] : The port used for zookeeper elections (default=3888)
  • node["zookeeper"]["version"] : The version of the Serf agent to install (default="3.4.5")
  • node["zookeeper"]["mirror"] : The URL to the mirror that hosts the zookeeper binary (default=
  • node["zookeeper"]["binary_url"] : The full binary url of Zookeeper. If you override this value make sure to provide a valid and up to date value for node["zookeeper"]["version"] (default=File.join node["zookeeper"]["mirror"], "zookeeper-#{node["zookeeper"]["version"]}", "zookeeper-#{node["zookeeper"]["version"]}.tar.gz")
  • node["zookeeper"]["base_directory"] : The base directory Zookeeper should be installed into (default="/opt/zookeeper")
  • node["zookeeper"]["log_directory"] : The log directory for Zookeeper (default="#{node["zookeeper"]["base_directory"]}/logs")
  • node["zookeeper"]["zoo.cfg"][*] : The key/values set for the zoo.cfg config file (see attributes file for defaults)
  • node["zookeeper"][""][*] : The key/values set for the config file (see attributes file for defaults)

Dependent cookbooks

java >= 0.0.0
ulimit >= 0.0.0

Contingent cookbooks

There are no cookbooks that are contingent upon this one.

Change Log

0.5.0 - 06-23-2015

  • [Enhancement] Issue-24 : Fix up tests
  • [Enhancement] Issue-23 : Recipe downgrades java to 1.6
  • [Enhancement] Issue-20 : Add test zkcli works
  • [Enhancement] Issue-13 : Use ulimit cookbook

0.4.0 - 10-20-2014

  • [Enhancement] Issue-19 : Documentation update for default ports
  • [Enhancement] Issue-18 : Match any IP address, not just the default

0.3.2 - 09-09-2014

0.3.1 - 09-09-2014

  • [Bug] Issue-14 : attributes? not a method -- affects ec2 provisioning

0.3.0 - 08-21-2014

  • [Enhancement] Issue-10 : Additional attribute tweaks

0.2.2 - 08-21-2014

  • [Bug] Issue-11 : Release without PaxHeaders

0.2.1 - 07-24-2014

  • [Enhancement] Issue-9 : Set zookeeper log directory by default
  • [Bug] Issue-8 : Client port is always appended to hosts
  • [Enhancement] Issue-2 : Add tests

0.2.0 - 07-15-2014

  • [Feature] Issue-7 : Additional attributes

0.1.3 - 07-12-2014

0.1.2 - 06-30-2014

  • [Bug] Issue-5 : Init script does not support chkconfig

0.1.1 - 06-21-2014

  • [Bug] Issue-4 : Metadata does not include java depends

0.1.0 - 06-21-2014

  • [Feature] Issue-1 : Initial Cookbook

Foodcritic Metric

0.5.0 passed this metric