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


consul (79) Versions 1.0.0

Application cookbook which installs and configures Consul.

cookbook 'consul', '= 1.0.0', :supermarket
cookbook 'consul', '= 1.0.0'
knife supermarket install consul
knife supermarket download consul
Quality 0%


Join the chat at
Build Status
Code Coverage

Application cookbook which installs and configures Consul.

Consul is a tool for discovering and configuring services within your
infrastructure. This is an application cookbook which takes a
simplified approach to configuring and installing
Consul. Additionally, it provides Chef primitives for more advanced

Basic Usage

For most infrastructure we suggest first starting with the default
recipe. This installs and configures Consul from the latest supported
release. It is also what is used to certify platform support through
the use of our integration tests.

This cookbook provides node attributes which are used to fine tune
the default recipe which installs and configures Consul. These values
are passed directly into the Chef resource/providers which are exposed
for more advanced configuration.

Out of the box the following platforms are certified to work and are
tested using our Test Kitchen configuration. Additional platforms
may work, but your mileage may vary.
- CentOS (RHEL) 6.6, 7.1
- Ubuntu 12.04, 14.04
- Windows

Advanced Usage

As explained above this cookbook provides Chef primitives in the form
of resource/provider to further manage the install and configuration
of Consul. These primitives are what is used in the default recipe,
and should be used in your own wrapper cookbooks for more
advanced configurations.


It is very important to understand that each resource/provider has
defaults for some properties. Any changes to a resource's default
properties may need to be also changed in other resources. The best
example is the Consul configuration directory.

In the example below we're going to change the configuration file from
the default (/etc/consul.json) to one that may be on a special volume.
It is obvious that we need to change the path where consul_config
writes its file to, but it is less obvious that this needs to be
passed into consul_service.

Inside of a recipe in your wrapper cookbook you'll want to do
something like the following block of code. It uses the validated
input from the configuration resource and passes it into the service
resource. This ensures that we're using the same data.
config = consul_config '/data/consul/default.json'
consul_service 'consul' do
config_file config.path


In order to provide an idempotent implementation of Consul
watches and definitions. We write these out as
a separate configuration file in the JSON file format. The provider
for both of these resources are identical in functionality.

Below is an example of writing a Consul service definition for
the master instance of Redis. We pass in several parameters and tell
the resource to notify the proper instance of the Consul service to
consul_definition 'redis' do
type 'service'
parameters(tags: %w{master}, address: '', port: 6379, interval: '30s')
notifies :reload, 'consul_service[consul]', :delayed

A check definition can easily be added as well. You simply have
to change the type and pass in the correct parameters. The definition
below checks memory utilization using a script on a ten second interval.
consul_definition 'mem-util' do
type 'check'
parameters(script: '/usr/local/bin/', interval: '10s')
notifies :reload, 'consul_service[consul]', :delayed

Finally, a watch is created below to tell the agent to monitor to
see if an application has been deployed. Once that application is
deployed a script is run locally. This can be used, for example, as a
lazy way to clear a HTTP disk cache.
consul_watch 'app-deploy' do
type 'event'
parameters(handler: '/usr/local/bin/')
notifies :reload, 'consul_service[consul]', :delayed

A keen eye would notice that we are delaying the reload of the Consul
service instance
. The reason we do this is to minimize the number of
times we need to tell Consul to actually reload configurations. If
there are several definitions this may save a little time off your
Chef run.


The command-line agent provides a mechanism to facilitate remote
execution. For example, this can be used to run the uptime command
across your fleet of nodes which are hosting a particular API service.
consul_execute 'uptime' do
options(service: 'api')

All of the options available on the command-line can be passed
into the resource. This could potentially be a very dangerous
operation. You should absolutely understand what you are doing. By the
nature of this command it is impossible for it to be idempotent.




Fixes several bugs, minor enhancements and changes default version of
Consul to 0.5.2.

  • Enhancements

    • Node attribute for specifying Consul log file. @darron
    • Recipe no longer tries to create directories twice. @tiwilliam
    • Add packagecloud install method. @darron
    • Add 'rejoin_after_leave' option. @arodd
    • Add LWRP for services watch. @hirocaster
  • Bug Fixes

    • #152 Remove +x permissions on upstart/systemd configs. @dpkp
    • #158 Fix sysvinit script by not quoting commands. @hatchetation
    • #172 Adds missing bracket to restart subscription. @YuukiARIA
    • #178 Ensures GOMAXPROCS is at least 2. @tgwizard


  • Bug Fixes
    • Lock to Chef 11 compatible version of libarchive cookbook


  • Enhancements
  • Bug Fixes

    • Remove hard dependency on chef-provisioning cookbook.
    • Sets correct ownership to Consul run user/group on service directories. @thedebugger
  • Removes support for EL5 (CentOS 5) and Ubuntu 10.04.


  • Bug Fixes
    • Export GOMAXPROCS when using runit service style


  • Bug Fixes
    • Set GOMAXPROCS when using runit service style


  • Bug Fixes
    • Vanilla init script now points to the proper Consul binary and data dir


  • Enhancements

    • Upgrading from one version to another of Consul is now supported. The Consul service will automatically restart after upgrade.
  • Bug Fixes

    • Partial convergeances will now gracefully recover on the next chef run
    • Upstart will now respawn Consul on crash
    • It is no longer possible to set an invalid install method
  • Backwards incompatible changes

    • 'consul/ui_dir' attribute was removed. This will automatically be placed within the directory configured by 'consul/data_dir' as 'ui'


  • Bug Fixes
    • Fixed: Reloading the Consul service when using the runit init style will


  • Enhancements

    • Added cluster recipe for easily provisioning new Consul clusters. See the README for details
    • Added support for additional options for service_config
    • Added support for Ubuntu 10.04
    • Allow custom data bag / data bag item for Consul encrypt. Default data bag is still consul and default item is still encrypt
    • Bump support for Golan cookbook ~> 1.4
    • Added consul/retry_on_join attribute which to specify retry_join strategy instead of the default: start_join
    • Added consul_service_watch LWRP
  • Bug Fixes

    • No longer overwrite service user/group attribute when using non-runit init styles
    • Setting the version attribute will now point to the appropriate download URL
    • Use ID attribute to identify consul check definition files instead of name. If no ID is present name will be used


  • Add support for TLS, and gossip encryption

New features:
- Add Chef Provisioning recipe for bootstrapping a cluster.
- Add LWRP for defining an event watch (thanks @ericfode


  • Adds server list to a consul instance running as a cluster with a bootstrap_expect value greater than one.


  • Fix race condition when installing Consul as a runit service
  • Documentation fixes


Bumps default version of Consul to 0.4.0


Bumps default version of Consul to 0.3.1.

Adds support to bind to the IP of a named interface.
- bind_interface, advertise_interface, client_interface attributes
(thanks @romesh-mccullough)

Test/Quality Coverage
- Expands test coverage to the consul::ui and consul::_service recipes.
- Passes some more rubocop and foodcritic code quality tests.
- Only test in Travis against rubies of future past.


Adds ChefSpec tests and software lint/metrics.

Breaking Changes
- Renames binary_install recipe to install_binary
- Renames source_install recipe to source_binary


Bumps the release of Consul to 0.3.0.

Adds Service LWRP (thanks @reset!)


Bumps the release of Consul to 0.2.0.

Adds consul::service recipe.
Adds more tests.

Bug Smashing
- Source installation now works properly.
- Test Kitchen shows all green!


Initial release of Consul cookbook.

Source and binary installation recipes.

Foodcritic Metric

1.0.0 failed this metric

FC031: Cookbook without metadata file: /tmp/cook/ce6576f757a829df16ca1fdb/consul/metadata.rb:1
FC045: Consider setting cookbook name in metadata: /tmp/cook/ce6576f757a829df16ca1fdb/consul/metadata.rb:1