Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic bootstrapping for consul cluster of multiple servers with the bootstrap_expect value greater than one #53

Merged
merged 5 commits into from
Oct 17, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -67,4 +67,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