Skip to content

Commit

Permalink
Upgrade and Downgrade with url
Browse files Browse the repository at this point in the history
  • Loading branch information
thijsterlouw committed May 18, 2015
1 parent b827b5a commit 10d8191
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 20 deletions.
37 changes: 25 additions & 12 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,50 @@

if $consul::install_method == 'url' {

$version = $consul::version
$consul_archive_target = "consul_${version}.zip"
$consul_web_ui_archive_target = "consul_web_ui_${version}.zip"

if $::operatingsystem != 'darwin' {
ensure_packages(['unzip'])
}
staging::file { 'consul.zip':
staging::file { $consul_archive_target:
source => $consul::download_url
} ->
staging::extract { 'consul.zip':
target => $consul::bin_dir,
creates => "${consul::bin_dir}/consul",
file { "${consul::bin_dir}/consul_${version}/":
ensure => 'directory',
owner => 'root',
group => 0,
mode => '0755',
} ->
staging::extract { $consul_archive_target:
target => "${consul::bin_dir}/consul_${version}/",
creates => "${consul::bin_dir}/consul_${version}/consul",
} ->
file { "${consul::bin_dir}/consul":
owner => 'root',
group => 0, # 0 instead of root because OS X uses "wheel".
mode => '0555',
owner => 'root',
group => 0, # 0 instead of root because OS X uses "wheel".
mode => '0555',
target => "${consul::bin_dir}/consul_${version}/consul",
notify => Service['consul'],
}


if ($consul::ui_dir and $consul::data_dir) {
file { "${consul::data_dir}/${consul::version}_web_ui":
file { "${consul::data_dir}/${version}_web_ui":
ensure => 'directory',
owner => 'root',
group => 0, # 0 instead of root because OS X uses "wheel".
mode => '0755',
} ->
staging::deploy { 'consul_web_ui.zip':
staging::deploy { $consul_web_ui_archive_target:
source => $consul::ui_download_url,
target => "${consul::data_dir}/${consul::version}_web_ui",
creates => "${consul::data_dir}/${consul::version}_web_ui/dist",
target => "${consul::data_dir}/${version}_web_ui",
creates => "${consul::data_dir}/${version}_web_ui/dist",
}
file { $consul::ui_dir:
ensure => 'symlink',
target => "${consul::data_dir}/${consul::version}_web_ui/dist",
target => "${consul::data_dir}/${version}_web_ui/dist",
}
}

Expand Down
2 changes: 1 addition & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
$package_ensure = 'latest'
$ui_package_name = 'consul_ui'
$ui_package_ensure = 'latest'
$version = '0.5.0'
$version = hiera('consul::version', '0.5.0') # ensure defaults resolve from hiera as well

case $::architecture {
'x86_64', 'amd64': { $arch = 'amd64' }
Expand Down
14 changes: 7 additions & 7 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
}}
it { expect { should compile }.to raise_error(/is not a boolean/) }
end

context 'When passing a non-bool as manage_service' do
let(:params) {{
:manage_service => 'hello'
Expand Down Expand Up @@ -72,21 +72,21 @@
end

context "When installing via URL by default" do
it { should contain_staging__file('consul.zip').with(:source => 'https://dl.bintray.com/mitchellh/consul/0.5.0_linux_amd64.zip') }
it { should contain_staging__file('consul_0.5.0.zip').with(:source => 'https://dl.bintray.com/mitchellh/consul/0.5.0_linux_amd64.zip') }
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://dl.bintray.com/mitchellh/consul/42_linux_amd64.zip') }
it { should contain_staging__file('consul_0.5.0.zip').with(:source => 'https://dl.bintray.com/mitchellh/consul/42_linux_amd64.zip') }
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.0.zip').with(:source => 'http://myurl') }
end


Expand Down Expand Up @@ -117,7 +117,7 @@
'ui_dir' => '/dir1/dir2',
},
}}
it { should contain_staging__file('consul_web_ui.zip').with(:source => 'https://dl.bintray.com/mitchellh/consul/0.5.0_web_ui.zip') }
it { should contain_staging__file('consul_web_ui_0.5.0.zip').with(:source => 'https://dl.bintray.com/mitchellh/consul/0.5.0_web_ui.zip') }
end

context "When installing UI via URL by with a special version" do
Expand All @@ -128,7 +128,7 @@
'ui_dir' => '/dir1/dir2',
},
}}
it { should contain_staging__file('consul_web_ui.zip').with(:source => 'https://dl.bintray.com/mitchellh/consul/42_web_ui.zip') }
it { should contain_staging__file('consul_web_ui_0.5.0.zip').with(:source => 'https://dl.bintray.com/mitchellh/consul/42_web_ui.zip') }
end

context "When installing UI via URL by with a custom url" do
Expand All @@ -139,7 +139,7 @@
'ui_dir' => '/dir1/dir2',
},
}}
it { should contain_staging__deploy('consul_web_ui.zip').with(:source => 'http://myurl') }
it { should contain_staging__deploy('consul_web_ui_0.5.0.zip').with(:source => 'http://myurl') }
end

context "By default, a user and group should be installed" do
Expand Down

0 comments on commit 10d8191

Please sign in to comment.