diff --git a/.kitchen.yml b/.kitchen.yml index 87e3194f..08ab48d3 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -6,18 +6,14 @@ provisioner: name: chef_zero platforms: - - name: ubuntu-12.04 - name: ubuntu-14.04 + - name: ubuntu-12.04 + - name: ubuntu-10.04 + - name: centos-7.0 - name: centos-6.5 - attributes: - golang: - install_dir: '/usr' - name: centos-5.10 run_list: - recipe[yum-repoforge::default] - attributes: - golang: - install_dir: '/usr' suites: - name: default @@ -29,6 +25,12 @@ suites: bind_interface: eth0 advertise_interface: eth0 encrypt: CGXC2NsXW4AvuB4h5ODYzQ== + - name: source + run_list: + - recipe[consul::default] + attributes: + consul: + install_method: source - name: runit run_list: - recipe[consul::default] diff --git a/CHANGELOG.md b/CHANGELOG.md index a90eba2c..220a3ee5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ -# 0.5.0 +<<<<<<< HEAD +# 0.6.0 * Add support for TLS, and gossip encryption +New features: +- Add [Chef Provisioning][7] recipe for bootstrapping a cluster. +- Add LWRP for defining [an event watch][8] (thanks [@ericfode][9] + # 0.4.4 * Adds server list to a consul instance running as a cluster with a `bootstrap_expect` value greater than one. @@ -56,3 +61,6 @@ Source and binary installation recipes. [4]: http://acrmp.github.io/foodcritic/ [5]: https://github.com/romesh-mccullough [6]: https://github.com/bbatsov/rubocop +[7]: https://github.com/opscode/chef-provisioning +[8]: http://www.consul.io/docs/commands/watch.html +[9]: https://github.com/ericfode diff --git a/README.md b/README.md index 084dbb07..bf37fd5f 100644 --- a/README.md +++ b/README.md @@ -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 @@ -331,14 +331,31 @@ Following attributes, if exist in the [encrypted databag][7], override the node ## Usage +The easiest way to bootstrap a cluster is to use the cluster recipe +and use [Chef provisioning][8] 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][9] 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][10] 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 { @@ -349,8 +366,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 { @@ -361,10 +380,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 { @@ -440,4 +457,6 @@ Created and maintained by [John Bellone][3] [@johnbellone][2] ( +# 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 diff --git a/metadata.rb b/metadata.rb index 7a13ee82..7fbcfc29 100644 --- a/metadata.rb +++ b/metadata.rb @@ -2,8 +2,8 @@ maintainer 'John Bellone' maintainer_email 'jbellone@bloomberg.net' license 'Apache v2.0' -description 'Installs/Configures consul' -long_description 'Installs/Configures consul' +description 'Installs/Configures Consul client, server and UI.' +long_description 'Installs/Configures Consul client, server and UI.' version '0.6.0' recipe 'consul', 'Installs and starts consul service.' @@ -17,9 +17,12 @@ supports name, '~> 5.10' end +supports 'ubuntu', '= 10.04' supports 'ubuntu', '= 12.04' supports 'ubuntu', '= 14.04' +suggests 'chef-provisioning' + depends 'ark' depends 'golang', '~> 1.3.0' depends 'runit' diff --git a/recipes/install_binary.rb b/recipes/install_binary.rb index 829f706b..be60c214 100644 --- a/recipes/install_binary.rb +++ b/recipes/install_binary.rb @@ -25,7 +25,7 @@ path node['consul']['install_dir'] version node['consul']['version'] checksum install_checksum - url ::URI.join(node['consul']['base_url'], "#{install_version}.zip").to_s + url node['consul']['base_url'] % { version: install_version } action :dump end diff --git a/recipes/ui.rb b/recipes/ui.rb index 6104a6f0..7030fa1e 100644 --- a/recipes/ui.rb +++ b/recipes/ui.rb @@ -23,5 +23,5 @@ home_dir node['consul']['ui_dir'] version node['consul']['version'] checksum install_checksum - url ::URI.join(node['consul']['base_url'], "#{install_version}.zip").to_s + url node['consul']['base_url'] % { version: install_version } end diff --git a/spec/unit/attributes/default_spec.rb b/spec/unit/attributes/default_spec.rb index f92c4574..93021cd2 100644 --- a/spec/unit/attributes/default_spec.rb +++ b/spec/unit/attributes/default_spec.rb @@ -4,6 +4,6 @@ let(:chef_run) { ChefSpec::Runner.new(platform: 'ubuntu', version: '12.04').converge(described_recipe) } context 'sets default attributes' do - it { expect(chef_run.node.consul.base_url).to eq('https://dl.bintray.com/mitchellh/consul/') } + it { expect(chef_run.node.consul.base_url).to eq("https://dl.bintray.com/mitchellh/consul/%{version}.zip") } end end diff --git a/spec_helper.rb b/spec_helper.rb deleted file mode 100644 index 4ec6690e..00000000 --- a/spec_helper.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'serverspec' -set :backend, :exec - -RSpec.configure do |c| - c.path = '/usr/local/bin:/sbin:/bin:/usr/bin' -end