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

RSS

consul (77) Versions 0.7.0

Application cookbook which installs and configures Consul.

Policyfile
Berkshelf
Knife
cookbook 'consul', '= 0.7.0', :supermarket
cookbook 'consul', '= 0.7.0'
knife supermarket install consul
knife supermarket download consul
README
Dependencies
Changelog
Quality 0%

consul-cookbook

Release
Build Status
Code Coverage

Installs and configures Consul client, server and UI.

Supported Platforms

  • CentOS 5.10, 6.5, 7.0
  • RHEL 5.10, 6.5, 7.0
  • Ubuntu 10.04, 12.04, 14.04

Attributes

<table>
<tr>
<th>Key</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><tt>['consul']['version']</tt></td>
<td>String</td>
<td>Version to install</td>
<td><tt>0.4.1</tt></td>
</tr>
<tr>
<td><tt>['consul']['base_url']</tt></td>
<td>String</td>
<td>Base URL for binary downloads</td>
<td><tt>https://dl.bintray.com/mitchellh/consul/</tt></td>
</tr>
<tr>
<td><tt>['consul']['encrypt']</tt></td>
<td>String</td>
<td>Encryption string for consul cluster.</td>
<td><tt>nil</tt></td>
</tr>
<tr>
<td><tt>['consul']['install_method']</tt></td>
<td>String</td>
<td>Method to install consul with when using default recipe: binary or source</td>
<td><tt>binary</tt></td>
</tr>
<tr>
<td><tt>['consul']['install_dir']</tt></td>
<td>String</td>
<td>Directory to install binary to.</td>
<td><tt>/usr/local/bin</tt></td>
</tr>
<tr>
<td><tt>['consul']['service_mode']</tt></td>
<td>String</td>
<td>Mode to run consul as: bootstrap, cluster, server, or client</td>
<td><tt>bootstrap</tt></td>
</tr>
<tr>
<td><tt>['consul'][bootstrap_expect]</tt></td>
<td>String</td>
<td>When bootstrapping a cluster, the number of server nodes to expect.</td>
<td><tt>nil</tt></td>
</tr>
<tr>
<td><tt>['consul']['data_dir']</tt></td>
<td>String</td>
<td>Location to store consul's data in</td>
<td><tt>/var/lib/consul</tt></td>
</tr>
<tr>
<td><tt>['consul']['config_dir']</tt></td>
<td>String</td>
<td>Location to read service definitions from (directoy will be created)</td>
<td><tt>/etc/consul.d</tt></td>
</tr>
<tr>
<td><tt>['consul']['servers']</tt></td>
<td>Array Strings</td>
<td>Consul servers to join</td>
<td><tt>[]</tt></td>
</tr>
<tr>
<td><tt>['consul']['retry_on_join']</tt></td>
<td>Boolean</td>
<td>Set to true to wait for servers to be up before try to elect a leader</td>
<td><tt>false</tt></td>
</tr>
<tr>
<td><tt>['consul']['bind_addr']</tt></td>
<td>String</td>
<td>address that should be bound to for internal cluster communications</td>
<td><tt>0.0.0.0</tt></td>
</tr>
<tr>
<td><tt>['consul']['datacenter']</tt></td>
<td>String</td>
<td>Name of Datacenter</td>
<td><tt>dc1</tt></td>
</tr>
<tr>
<td><tt>['consul']['domain']</tt></td>
<td>String</td>
<td>Domain for service lookup dns queries</td>
<td><tt>.consul</tt></td>
</tr>
<tr>
<td><tt>['consul']['enable_syslog']</tt></td>
<td>Boolean</td>
<td>enables logging to syslog</td>
<td><tt>nil</tt></td>
</tr>
<tr>
<td><tt>['consul']['log_level']</tt></td>
<td>String</td>
<td>
The level of logging to show after the Consul agent has started.
Available: "trace", "debug", "info", "warn", "err"
</td>
<td><tt>info</tt></td>
</tr>
<tr>
<td><tt>['consul']['node_name']</tt></td>
<td>String</td>
<td>The name of this node in the cluster</td>
<td>hostname of the machine</td>
</tr>
<tr>
<td><tt>['consul']['advertise_addr']</tt></td>
<td>String</td>
<td>address that we advertise to other nodes in the cluster</td>
<td>Value of <i>bind_addr</i></td>
</tr>
<tr>
<td><tt>['consul']['init_style']</tt></td>
<td>String</td>
<td>Service init mode for running consul as: init or runit</td>
<td><tt>init</tt></td>
</tr>
<tr>
<td><tt>['consul']['service_user']</tt></td>
<td>String</td>
<td>For runit service: run consul as this user (init uses 'root')</td>
<td><tt>consul</tt></td>
</tr>
<tr>
<td><tt>['consul']['service_group']</tt></td>
<td>String</td>
<td>For runit service: run consul as this group (init uses 'root')</td>
<td><tt>consul</tt></td>
</tr>
<tr>
<td><tt>['consul']['bind_interface']</tt></td>
<td>String</td>
<td>
Interface to bind to, such as 'eth1'. Sets bind_addr
attribute to the IP of the specified interface if it exists.
</td>
<td><tt>nil</tt></td>
</tr>
<tr>
<td><tt>['consul']['advertise_interface']</tt></td>
<td>String</td>
<td>
Interface to advertise, such as 'eth1'. Sets advertise_addr
attribute to the IP of the specified interface if it exists.
</td>
<td><tt>nil</tt></td>
</tr>
<tr>
<td><tt>['consul']['extra_params']</tt></td>
<td>hash</td>
<td>
Pass a hash of extra params to the default.json config file
</td>
<td><tt>{}</tt></td>
</tr>
<tr>
<td><tt>['consul']['encrypt_enabled']</tt></td>
<td>Boolean</td>
<td>
To enable Consul gossip encryption
</td>
<td><tt>false</tt></td>
</tr>
<tr>
<td><tt>['consul']['verify_incoming']</tt></td>
<td>Boolean</td>
<td>
If set to True, Consul requires that all incoming connections make use of TLS.
</td>
<td><tt>false</tt></td>
</tr>
<tr>
<td><tt>['consul']['verify_outgoing']</tt></td>
<td>Boolean</td>
<td>
If set to True, Consul requires that all outgoing connections make use of TLS.
</td>
<td><tt>false</tt></td>
</tr>
<tr>
<td><tt>['consul']['key_file']</tt></td>
<td>String</td>
<td>
The content of PEM encoded private key
</td>
<td><tt>nil</tt></td>
</tr>
<tr>
<td><tt>['consul']['key_file_path']</tt></td>
<td>String</td>
<td>
Path where the private key is stored on the disk
</td>
<td><tt>/etc/consul.d/key.pem</tt></td>
</tr>
<tr>
<td><tt>['consul']['ca_file']</tt></td>
<td>String</td>
<td>
The content of PEM encoded ca cert
</td>
<td><tt>nil</tt></td>
</tr>
<tr>
<td><tt>['consul']['ca_file_path']</tt></td>
<td>String</td>
<td>
Path where ca is stored on the disk
</td>
<td><tt>/etc/consul.d/ca.pem</tt></td>
</tr>
<tr>
<td><tt>['consul']['cert_file']</tt></td>
<td>String</td>
<td>
The content of PEM encoded cert. It should only contain the public key.
</td>
<td><tt>nil</tt></td>
</tr>
<tr>
<td><tt>['consul']['cert_file_path']</tt></td>
<td>String</td>
<td>
Path where cert is stored on the disk
</td>
<td><tt>/etc/consul.d/cert.pem</tt></td>
</tr>
</table>

Databag Attributes (optional)

Following attributes, if exist in the encrypted databag, override the node attributes

<table>
<tr>
<th>Key</th>
<th>Databag item</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td><tt>key_file</tt></td>
<td>['consul']['encrypt']</td>
<td>String</td>
<td>The content of PEM encoded private key</td>
</tr>
<tr>
<td><tt>key_file_{fqdn}</tt></td>
<td>['consul']['encrypt']</td>
<td>String</td>
<td>Node's(identified by fqdn) unique PEM encoded private key. If it exists, it will override the databag and node key_file attribute</td>
</tr>
<tr>
<td><tt>ca_file</tt></td>
<td>['consul']['encrypt']</td>
<td>String</td>
<td>The content of PEM encoded ca cert</td>
</tr>
<tr>
<td><tt>encrypt</tt></td>
<td>['consul']['encrypt']</td>
<td>String</td>
<td>Consul Gossip encryption key</td>
</tr>
<tr>
<td><tt>cert_file</tt></td>
<td>['consul']['encrypt']</td>
<td>String</td>
<td>The content of PEM encoded cert</td>
</tr>
<tr>
<td><tt>cert_file_{fqdn}</tt></td>
<td>['consul']['encrypt']</td>
<td>String</td>
<td>Node's(identified by fqdn) unique PEM encoded cert. If it exists, it will override the databag and node cert_file attribute</td>
</tr>
</table>

Consul UI Attributes

<table>
<tr>
<th>Key</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><tt>['consul']['client_address']</tt></td>
<td>String</td>
<td>Address to bind to</td>
<td><tt>0.0.0.0</tt></td>
</tr>
<tr>
<td><tt>['consul']['client_interface']</tt></td>
<td>String</td>
<td>
Interface to advertise, such as 'eth1'. Sets advertise_addr
attribute to the IP of the specified interface if it exists.
</td>
<td><tt>nil</tt></td>
</tr>
<tr>
<td><tt>['consul']['ui_dir']</tt></td>
<td>String</td>
<td>Location to download the UI to</td>
<td><tt>/var/lib/consul/ui</tt></td>
</tr>
<tr>
<td><tt>['consul']['serve_ui']</tt></td>
<td>Boolean</td>
<td>Determines whether the consul service also serve's the UI</td>
<td><tt>false</tt></td>
</tr>
</table>

Usage

The easiest way to bootstrap a cluster is to use the cluster recipe
and use Chef provisioning which is a relatively new
extension. This extension allows you to use any driver and easily
stand up a cluster. Once the Chef Development Kit has been
installed you can run the following command to provision a cluster.

gem install chef-provisioning chef-provisioning-fog
export CHEF_DRIVER=fog:AWS
chef-client -z cluster.rb

Please follow the Chef provisioning README which provides more
detailed information about provisioning. You'll need to configure
your credentials prior to provisioning.

consul::default

The default recipe will install the Consul agent using the
consul::install_binary recipe. It will also configure and
start consul at the machine boot.

consul::install_binary

If you only wish to simply install the binary from the official
mirror you simply include consul::install_binary in your node's
run_list:

{
  "run_list": [
    "recipe[consul::install_binary]"
  ]
}

consul::install_source

Instead if you wish to install Consul from source you simply need
to include consul::install_source in your node's run_list. This
will also configure the Go language framework on the node to build
the application.

{
  "run_list": [
    "recipe[consul::install_source]"
  ]
}

consul::ui

Installing the separate Consul UI simply requires you to include
the consul::ui recipe in your node's run_list.

{
  "run_list": [
    "recipe[consul::ui]"
  ]
}

LWRP

Adding key watch
consul_key_watch_def 'key-watch-name' do
  key "/key/path"
  handler "chef-client"
end
Adding event watch
consul_event_watch_def 'event-name' do
  handler "chef-client"
end
Adding service watch
consul_service_watch_def 'service-name' do
      passingonly true
  handler "chef-client"
end
Adding service without check
consul_service_def 'voice1' do
  port 5060
  tags ['_sip._udp']
  notifies :reload, 'service[consul]'
end
Adding service with check
consul_service_def 'voice1' do
  port 5060
  tags ['_sip._udp']
  check(
    interval: '10s',
    script: 'echo ok'
  )
  notifies :reload, 'service[consul]'
end
Removing service
consul_service_def 'voice1' do
  action :delete
  notifies :reload, 'service[consul]'
end

Be sure to notify the Consul resource to restart when your service def changes.

Getting Started

To bootstrap a consul cluster follow the following steps:
0. Make sure that ports 8300-8302 (by default, if you configured different ones open those) UDP/TCP are all open.
1. Bootstrap a few (preferablly 3 nodes) to be your consul servers, these will be the KV masters.
2. Put node['consul']['servers'] =["Array of the bootstrapped servers ips or dns names"] in your environment.
3. Apply the consul cookbook to these nodes with node['consul']['service_mode'] = 'cluster' (I put this in this in a CONSUL_MASTER role).
4. Let these machines converge, once you can run consul members and get a list of all of the servers your ready to move on
5. Apply the consul cookbook to the rest of your nodes with node['consul']['service_mode'] = 'client' (I put this in the environment)
6. Start added services and checks to your cookbooks.
7. If you want to get values out of consul to power your chef, curl localhost:8500/v1/kv/key/path?raw in your cookbook.

Authors

Created and maintained by John Bellone @johnbellone (jbellone@bloomberg.net) and a growing community of contributors.

0.7.0

  • 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

0.6.0

  • 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

0.4.4

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

0.4.3

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

0.4.2

Bumps default version of Consul to 0.4.0

0.4.1

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.

0.4.0

Adds ChefSpec tests and software lint/metrics.

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

0.3.0

Bumps the release of Consul to 0.3.0.

Adds Service LWRP (thanks @reset!)

0.2.0

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!

0.1.0

Initial release of Consul cookbook.

Source and binary installation recipes.

Foodcritic Metric
            

0.7.0 failed this metric

FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b2ae0163d8a364d02d9f72a0/consul/recipes/_service.rb:124
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b2ae0163d8a364d02d9f72a0/consul/templates/default/sv-consul-log-run.erb:2
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/b2ae0163d8a364d02d9f72a0/consul/templates/default/sv-consul-run.erb:2
FC019: Access node attributes in a consistent manner: /tmp/cook/b2ae0163d8a364d02d9f72a0/consul/recipes/_service.rb:124
FC021: Resource condition in provider may not behave as expected: /tmp/cook/b2ae0163d8a364d02d9f72a0/consul/providers/check_def.rb:21
FC023: Prefer conditional attributes: /tmp/cook/b2ae0163d8a364d02d9f72a0/consul/recipes/_service.rb:166
FC031: Cookbook without metadata file: /tmp/cook/b2ae0163d8a364d02d9f72a0/consul/metadata.rb:1
FC045: Consider setting cookbook name in metadata: /tmp/cook/b2ae0163d8a364d02d9f72a0/consul/metadata.rb:1