Skip to content

Commit

Permalink
Merge pull request #53 from ComparetheMarket/master
Browse files Browse the repository at this point in the history
Automatic bootstrapping for consul cluster of multiple servers with the bootstrap_expect value greater than one
  • Loading branch information
johnbellone committed Oct 17, 2014
2 parents 3b298b8 + b64db63 commit d75fe45
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 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
Expand Down
1 change: 1 addition & 0 deletions recipes/_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
service_config['server'] = true
if num_cluster > 1
service_config['bootstrap_expect'] = num_cluster
service_config['start_join'] = node['consul']['servers']
else
service_config['bootstrap'] = true
end
Expand Down
34 changes: 34 additions & 0 deletions spec/unit/recipes/_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,38 @@
expect(chef_run).to start_runit_service('consul')
end
end

context 'with a cluster service_mode, bootstrap_expect > 1, and a server list to join' do
let(:chef_run) do
ChefSpec::Runner.new(node_attributes) do |node|
node.set['consul']['service_mode'] = 'cluster'
node.set['consul']['bootstrap_expect'] = '3'
node.set['consul']['servers'] = [ 'server1', 'server2', 'server3' ]
end.converge(described_recipe)
end
it do
expect(chef_run).to create_file('/etc/consul.d/default.json')
.with_content(/start_join/)
.with_content(/server1/)
.with_content(/server2/)
.with_content(/server3/)
end
end

context 'with a cluster service_mode, bootstrap_expect = 1, and a server list' do
let(:chef_run) do
ChefSpec::Runner.new(node_attributes) do |node|
node.set['consul']['service_mode'] = 'cluster'
node.set['consul']['bootstrap_expect'] = '1'
node.set['consul']['servers'] = [ 'server1', 'server2', 'server3' ]
end.converge(described_recipe)
end
it do
expect(chef_run).to_not create_file('/etc/consul.d/default.json')
.with_content(/start_join/)
.with_content(/server1/)
.with_content(/server2/)
.with_content(/server3/)
end
end
end

0 comments on commit d75fe45

Please sign in to comment.