Skip to content

Commit

Permalink
Use data_dir as a the root of the archive path. Fixes voxpupuli#307
Browse files Browse the repository at this point in the history
  • Loading branch information
solarkennedy committed Jan 2, 2017
1 parent b8f7009 commit 205b76f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

case $::consul::install_method {
'url': {
$install_path = $::consul::archive_path
$install_prefix = pick($::consul::config_hash[data_dir], '/opt/consul')
$install_path = pick($::consul::archive_path, "${install_prefix}/archives")

# only notify if we are installing a new version (work around for switching to archive module)
if getvar('$::consul_version') != $::consul::version {
Expand Down
2 changes: 1 addition & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
class consul::params {
$acls = {}
$archive_path = '/opt/consul/archives'
$archive_path = ''
$bin_dir = '/usr/local/bin'
$checks = {}
$config_defaults = {}
Expand Down
16 changes: 10 additions & 6 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
:consul_version => 'unknown',
}
end
Puppet::Util::Log.level = :debug
Puppet::Util::Log.newdestination(:console)
# Installation Stuff
context 'On an unsupported arch' do
let(:facts) {{ :architecture => 'bogus' }}
Expand Down Expand Up @@ -163,8 +165,8 @@
'ui_dir' => '/dir1/dir2',
},
}}
it { should contain_archive('/opt/consul/archives/consul_web_ui-0.7.0.zip').with(:source => 'https://releases.hashicorp.com/consul/0.7.0/consul_0.7.0_web_ui.zip') }
it { should contain_file('/dir1/dir2').that_requires('Archive[/opt/consul/archives/consul_web_ui-0.7.0.zip]') }
it { should contain_archive('/dir1/archives/consul_web_ui-0.7.0.zip').with(:source => 'https://releases.hashicorp.com/consul/0.7.0/consul_0.7.0_web_ui.zip') }
it { should contain_file('/dir1/dir2').that_requires('Archive[/dir1/archives/consul_web_ui-0.7.0.zip]') }
it { should contain_file('/dir1/dir2').with(:ensure => 'symlink') }
end

Expand All @@ -176,7 +178,7 @@
'ui_dir' => '/dir1/dir2',
},
}}
it { should contain_archive('/opt/consul/archives/consul_web_ui-42.zip').with(:source => 'https://releases.hashicorp.com/consul/42/consul_42_web_ui.zip') }
it { should contain_archive('/dir1/archives/consul_web_ui-42.zip').with(:source => 'https://releases.hashicorp.com/consul/42/consul_42_web_ui.zip') }
end

context "When installing UI via URL when version < 0.6.0" do
Expand All @@ -187,7 +189,7 @@
'ui_dir' => '/dir1/dir2',
},
}}
it { should contain_archive('/opt/consul/archives/consul_web_ui-0.5.99.zip').with(:creates => %r{/dist$}) }
it { should contain_archive('/dir1/archives/consul_web_ui-0.5.99.zip').with(:creates => %r{/dist$}) }
it { should contain_file('/dir1/dir2').with(:target => %r{/dist$}) }
end

Expand All @@ -199,7 +201,7 @@
'ui_dir' => '/dir1/dir2',
},
}}
it { should contain_archive('/opt/consul/archives/consul_web_ui-0.6.0.zip').with(:creates => %r{/index\.html$}) }
it { should contain_archive('/dir1/archives/consul_web_ui-0.6.0.zip').with(:creates => %r{/index\.html$}) }
it { should contain_file('/dir1/dir2').with(:target => %r{_web_ui$}) }
end

Expand All @@ -211,7 +213,7 @@
'ui_dir' => '/dir1/dir2',
},
}}
it { should contain_archive('/opt/consul/archives/consul_web_ui-0.7.0.zip').with(:source => 'http://myurl') }
it { should contain_archive('/dir1/archives/consul_web_ui-0.7.0.zip').with(:source => 'http://myurl') }
end

context "By default, a user and group should be installed" do
Expand All @@ -226,10 +228,12 @@
},
}}
it { should contain_file('/dir1').with(:ensure => :directory) }
it { should contain_file('/dir1/archives').with(:ensure => :directory) }
end

context "When data_dir not provided" do
it { should_not contain_file('/dir1').with(:ensure => :directory) }
it { should contain_file('/opt/consul/archives').with(:ensure => :directory) }
end

context "When ui_dir is provided but not data_dir" do
Expand Down

0 comments on commit 205b76f

Please sign in to comment.