diff --git a/manifests/install.pp b/manifests/install.pp index d3f9691b..52314be4 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -15,17 +15,26 @@ case $consul::install_method { 'url': { - staging::file { 'consul.zip': - source => $consul::real_download_url + include staging + staging::file { "consul-${consul::version}.${consul::download_extension}": + source => $consul::real_download_url, } -> - staging::extract { 'consul.zip': - target => $consul::bin_dir, - creates => "${consul::bin_dir}/consul", + file { "${::staging::path}/consul-${consul::version}": + ensure => directory, } -> - file { "${consul::bin_dir}/consul": - owner => 'root', - group => 0, # 0 instead of root because OS X uses "wheel". - mode => '0555', + staging::extract { "consul-${consul::version}.${consul::download_extension}": + target => "${::staging::path}/consul-${consul::version}", + creates => "${::staging::path}/consul-${consul::version}/consul", + } -> + file { + "${::staging::path}/consul-${consul::version}/consul": + owner => 'root', + group => 0, # 0 instead of root because OS X uses "wheel". + mode => '0555'; + "${consul::bin_dir}/consul": + ensure => link, + notify => $consul::notify_service, + target => "${::staging::path}/consul-${consul::version}/consul"; } if ($consul::ui_dir and $consul::data_dir) { diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 239a1af4..6988b266 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -84,21 +84,25 @@ end context "When installing via URL by default" do - it { should contain_staging__file('consul.zip').with(:source => 'https://releases.hashicorp.com/consul/0.5.2/consul_0.5.2_linux_amd64.zip') } + it { should contain_staging__file('consul-0.5.2.zip').with(:source => 'https://releases.hashicorp.com/consul/0.5.2/consul_0.5.2_linux_amd64.zip') } + it { should contain_file('/usr/local/bin/consul').that_notifies('Class[consul::run_service]') } + #it { should contain_notify(['Class[consul::run_service]']) } end context "When installing via URL by with a special version" do let(:params) {{ :version => '42', }} - it { should contain_staging__file('consul.zip').with(:source => 'https://releases.hashicorp.com/consul/42/consul_42_linux_amd64.zip') } + it { should contain_staging__file('consul-42.zip').with(:source => 'https://releases.hashicorp.com/consul/42/consul_42_linux_amd64.zip') } + it { should contain_file('/usr/local/bin/consul').that_notifies('Class[consul::run_service]') } end context "When installing via URL by with a custom url" do let(:params) {{ :download_url => 'http://myurl', }} - it { should contain_staging__file('consul.zip').with(:source => 'http://myurl') } + it { should contain_staging__file('consul-0.5.2.zip').with(:source => 'http://myurl') } + it { should contain_file('/usr/local/bin/consul').that_notifies('Class[consul::run_service]') } end