Skip to content

Commit

Permalink
Fixes #76
Browse files Browse the repository at this point in the history
  • Loading branch information
what do you want? committed Nov 6, 2014
1 parent 9ed62cb commit d7ab428
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ Include `consul::ui` in your node's `run_list`:
consul_service_def 'voice1' do
port 5060
tags ['_sip._udp']
notifies :reload, 'service[consul]', :delayed
end

##### Adding service with check
Expand All @@ -263,20 +264,24 @@ Include `consul::ui` in your node's `run_list`:
interval: '10s',
script: 'echo ok'
)
notifies :reload, 'service[consul]', :delayed
end

##### Removing service

consul_service_def 'voice1' do
action :delete
notifies :reload, 'service[consul]', :delayed
end

NOTE: The consumer is resposible for notifying consul service. See #76 for more details.

#### Getting Started
To bootstrap a consul cluster follow the following steps:

1. Bootstrap a few (preferablly 3 nodes) to be your consul servers, these will be the KV masters.
2. Put `node['consul']['servers'] =["Array of the bootstrapped servers ips or dns names"]` in your environment.
3. Apply the consul cookbook to these nodes with `node['consul']['service_mode'] = 'cluster'` (I put this in this in a CONSUL_MASTER role).
3. Apply the consul cookbook to these nodes with `node['consul']['service_mode'] = 'cluster'` (I put this in this in a CONSUL_MASTER role).
4. Let these machines converge, once you can run `consul members` and get a list of all of the servers your ready to move on
5. Apply the consul cookbook to the rest of your nodes with `node['consul']['service_mode'] = 'client'` (I put this in the environment)
6. Start added services and checks to your cookbooks.
Expand Down
2 changes: 0 additions & 2 deletions providers/service_def.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def set_updated
mode 0600
content new_resource.to_json
action :create
notifies :reload, 'service[consul]', :delayed
end
end
end
Expand All @@ -39,7 +38,6 @@ def set_updated
set_updated do
file new_resource.path do
action :delete
notifies :reload, 'service[consul]', :delayed
end
end
end
5 changes: 0 additions & 5 deletions spec/unit/resources/service_def_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
'"script": "curl http://localhost:8888/health"'].each do |content|
expect(chef_run).to render_file(service_def_path)
.with_content(content)

expect(chef_run.file(service_def_path))
.to notify('service[consul]').to(:reload).delayed
end
end
end
Expand All @@ -24,8 +21,6 @@

it "de-register the service" do
expect(chef_run).to delete_file(service_def_path)
expect(chef_run.file(service_def_path))
.to notify('service[consul]').to(:reload).delayed
end
end
end

0 comments on commit d7ab428

Please sign in to comment.