Skip to content

Commit

Permalink
Merge pull request #39 from ravaa/master
Browse files Browse the repository at this point in the history
fix for #31 , implements support for bootstrap-expect and now creates the data_dir
  • Loading branch information
John Bellone committed Sep 7, 2014
2 parents 76e5e7e + c09dbfd commit 1f5f74a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,10 @@ suites:
consul:
serve_ui: true
client_interface: eth0
- name: cluster
run_list:
- recipe[consul::default]
attributes:
consul:
service_mode: cluster
bootstrap_expect: 1
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,14 @@ Installs and configures [Consul][1].
<tr>
<td><tt>['consul']['service_mode']</tt></td>
<td>String</td>
<td>Mode to run consul as: bootstrap, server, or client</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>
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
license 'Apache v2.0'
description 'Installs/Configures consul'
long_description 'Installs/Configures consul'
version '0.4.1'
version '0.4.2'

recipe 'consul', 'Installs and starts consul service.'
recipe 'consul::install_binary', 'Installs consul service from binary.'
Expand Down
9 changes: 9 additions & 0 deletions recipes/_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

# Configure directories
consul_directories = []
consul_directories << node['consul']['data_dir']
consul_directories << node['consul']['config_dir']
consul_directories << '/var/lib/consul'

Expand Down Expand Up @@ -64,11 +65,19 @@
# Determine service params
service_config = {}
service_config['data_dir'] = node['consul']['data_dir']
num_cluster = node['consul']['bootstrap_expect'].to_i

case node['consul']['service_mode']
when 'bootstrap'
service_config['server'] = true
service_config['bootstrap'] = true
when 'cluster'
service_config['server'] = true
if num_cluster > 1
service_config['bootstrap_expect'] = num_cluster
else
service_config['bootstrap'] = true
end
when 'server'
service_config['server'] = true
service_config['start_join'] = node['consul']['servers']
Expand Down

0 comments on commit 1f5f74a

Please sign in to comment.