From d7ab428014576b5f8720bcdb645338274adef100 Mon Sep 17 00:00:00 2001 From: what do you want? Date: Thu, 6 Nov 2014 10:37:39 -0800 Subject: [PATCH] Fixes #76 --- README.md | 9 +++++++-- providers/service_def.rb | 2 -- spec/unit/resources/service_def_spec.rb | 5 ----- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d8d8e4bc..14e53291 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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. diff --git a/providers/service_def.rb b/providers/service_def.rb index 495e2210..4d643f84 100644 --- a/providers/service_def.rb +++ b/providers/service_def.rb @@ -30,7 +30,6 @@ def set_updated mode 0600 content new_resource.to_json action :create - notifies :reload, 'service[consul]', :delayed end end end @@ -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 diff --git a/spec/unit/resources/service_def_spec.rb b/spec/unit/resources/service_def_spec.rb index 92b72ca0..bc139d98 100644 --- a/spec/unit/resources/service_def_spec.rb +++ b/spec/unit/resources/service_def_spec.rb @@ -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 @@ -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