Skip to content

Commit

Permalink
Add chef-provisioning recipe for easy bootstrapping.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbellone committed Nov 13, 2014
1 parent fe06931 commit 085cced
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 13 deletions.
44 changes: 32 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ consul-cookbook
[![Build Status](http://img.shields.io/travis/johnbellone/consul-cookbook.svg)][5]
[![Code Coverage](http://img.shields.io/coveralls/johnbellone/consul-cookbook.svg)][6]

Installs and configures [Consul][1].
Installs and configures [Consul][1] client, server and UI.

## Supported Platforms

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

## Attributes

Expand Down Expand Up @@ -212,14 +212,31 @@ Installs and configures [Consul][1].
</table>

## Usage
The easiest way to bootstrap a cluster is to use the cluster recipe
and use [Chef provisioning][7] 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][8] has been
installed you can run the following command to provision a cluster.

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

### consul::default
Please follow the [Chef provisioning README][9] which provides more
detailed information about provisioning. You'll need to configure
your credentials prior to provisioning.

This uses the binary installation recipe by default. It also starts consul at boot time.
### 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

Include `consul::install_binary` in your node's `run_list`:
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`:

```json
{
Expand All @@ -230,8 +247,10 @@ Include `consul::install_binary` in your node's `run_list`:
```

### consul::install_source

Include `consul::install_source` in your node's `run_list`:
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.

```json
{
Expand All @@ -242,10 +261,8 @@ Include `consul::install_source` in your node's `run_list`:
```

### consul::ui

This installs the UI into a specified directory.

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

```json
{
Expand Down Expand Up @@ -320,3 +337,6 @@ Created and maintained by [John Bellone][3] [@johnbellone][2] (<jbellone@bloombe
[4]: https://github.com/johnbellone/consul-cookbook/graphs/contributors
[5]: http://travis-ci.org/johnbellone/consul-cookbook
[6]: https://coveralls.io/r/johnbellone/consul-cookbook
[7]: https://github.com/opscode/chef-provisioning
[8]: https://github.com/opscode/chef-dk
[9]: https://github.com/opscode/chef-provisioning/blob/master/README.md
37 changes: 37 additions & 0 deletions cluster.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#
# Copyright 2014 John Bellone <jbellone@bloomberg.net>
# Copyright 2014 Bloomberg Finance L.P.
#
# 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.
#
num_quorum = ENV.fetch('CONSUL_QUORUM', 3)

batch = machine_batch do
1.upto(num_quorum).each do |index|
machine "consul-#{index}" do
recipe 'consul::default'
attributes(consul: { service_mode: 'cluster' })
end
end
end

include_recipe 'chef-sugar::default'
node.default['consul']['servers'] = batch.machines.each { |m| best_ip_for(m.node) }

machine 'consul-ui' do
recipe 'consul::ui'
attributes(consul: {
service_mode: 'client',
servers: node['consul']['servers']
})
end
3 changes: 2 additions & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
supports 'ubuntu', '= 14.04'

depends 'ark'
depends 'golang', '~> 1.5.0'
depends 'chef-provisioning'
depends 'golang', '~> 1.3.0'
depends 'runit'
depends 'yum-repoforge'

0 comments on commit 085cced

Please sign in to comment.