Skip to content

Commit 8cd0af1

Browse files
committed
Merge pull request #179 from mdelagrange/consul-reload-fix-2
fix 'consul reload' on custom rpc port
2 parents 3128b47 + cba89ed commit 8cd0af1

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

manifests/reload_service.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
if $consul::manage_service == true and $consul::service_ensure == 'running' {
1313
exec { 'reload consul service':
1414
path => [$consul::bin_dir,'/bin','/usr/bin'],
15-
command => 'consul reload',
15+
command => "consul reload -rpc-addr=${consul::rpc_addr}:${consul::rpc_port}",
1616
refreshonly => true,
1717
}
1818
}

spec/classes/init_spec.rb

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,56 @@
342342
it { should contain_file('/etc/init/consul.conf').with_content(/env GROUP=custom_consul_group/) }
343343
end
344344

345+
context "When consul is reloaded" do
346+
let (:params) {{
347+
:services => {
348+
'test_service1' => {}
349+
}
350+
}}
351+
let (:facts) {{
352+
:ipaddress_lo => '127.0.0.1'
353+
}}
354+
it {
355+
should contain_exec('reload consul service').
356+
with_command('consul reload -rpc-addr=127.0.0.1:8400')
357+
}
358+
end
359+
360+
context "When consul is reloaded on a custom port" do
361+
let (:params) {{
362+
:services => {
363+
'test_service1' => {}
364+
},
365+
:config_hash => {
366+
'ports' => {
367+
'rpc' => '9999'
368+
},
369+
'addresses' => {
370+
'rpc' => 'consul.example.com'
371+
}
372+
}
373+
}}
374+
it {
375+
should contain_exec('reload consul service').
376+
with_command('consul reload -rpc-addr=consul.example.com:9999')
377+
}
378+
end
379+
380+
context "When consul is reloaded with a default client_addr" do
381+
let (:params) {{
382+
:services => {
383+
'test_service1' => {}
384+
},
385+
:config_hash => {
386+
'client_addr' => '192.168.34.56',
387+
}
388+
}}
389+
it {
390+
should contain_exec('reload consul service').
391+
with_command('consul reload -rpc-addr=192.168.34.56:8400')
392+
}
393+
end
394+
345395
context "When the user provides a hash of services" do
346396
let (:params) {{
347397
:services => {

0 commit comments

Comments
 (0)