Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating staging file download to use the version and symlink #202

Merged
merged 3 commits into from
Dec 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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