Skip to content

Commit

Permalink
Merge pull request #202 from solarkennedy/DH-upgrade-consul-via-url
Browse files Browse the repository at this point in the history
Updating staging file download to use the version and symlink
  • Loading branch information
hopperd committed Dec 10, 2015
2 parents 87cd7ba + 944073f commit cbba32c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
27 changes: 18 additions & 9 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 7 additions & 3 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit cbba32c

Please sign in to comment.