diff --git a/manifests/reload_service.pp b/manifests/reload_service.pp index d182359e..af3d455b 100644 --- a/manifests/reload_service.pp +++ b/manifests/reload_service.pp @@ -12,7 +12,7 @@ if $consul::manage_service == true and $consul::service_ensure == 'running' { exec { 'reload consul service': path => [$consul::bin_dir,'/bin','/usr/bin'], - command => 'consul reload', + command => "consul reload -rpc-addr=${consul::rpc_addr}:${consul::rpc_port}", refreshonly => true, } } diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index ecbf576d..77737af7 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -342,6 +342,56 @@ it { should contain_file('/etc/init/consul.conf').with_content(/env GROUP=custom_consul_group/) } end + context "When consul is reloaded" do + let (:params) {{ + :services => { + 'test_service1' => {} + } + }} + let (:facts) {{ + :ipaddress_lo => '127.0.0.1' + }} + it { + should contain_exec('reload consul service'). + with_command('consul reload -rpc-addr=127.0.0.1:8400') + } + end + + context "When consul is reloaded on a custom port" do + let (:params) {{ + :services => { + 'test_service1' => {} + }, + :config_hash => { + 'ports' => { + 'rpc' => '9999' + }, + 'addresses' => { + 'rpc' => 'consul.example.com' + } + } + }} + it { + should contain_exec('reload consul service'). + with_command('consul reload -rpc-addr=consul.example.com:9999') + } + end + + context "When consul is reloaded with a default client_addr" do + let (:params) {{ + :services => { + 'test_service1' => {} + }, + :config_hash => { + 'client_addr' => '192.168.34.56', + } + }} + it { + should contain_exec('reload consul service'). + with_command('consul reload -rpc-addr=192.168.34.56:8400') + } + end + context "When the user provides a hash of services" do let (:params) {{ :services => {