From 205b76fe2996957de5e81889d42cc5330f9e5295 Mon Sep 17 00:00:00 2001 From: Kyle Anderson Date: Sun, 1 Jan 2017 20:39:56 -0800 Subject: [PATCH] Use data_dir as a the root of the archive path. Fixes #307 --- manifests/install.pp | 3 ++- manifests/params.pp | 2 +- spec/classes/init_spec.rb | 16 ++++++++++------ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index a51d5f28..ee019f81 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -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 { diff --git a/manifests/params.pp b/manifests/params.pp index db6d0e16..07d174e6 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -5,7 +5,7 @@ # class consul::params { $acls = {} - $archive_path = '/opt/consul/archives' + $archive_path = '' $bin_dir = '/usr/local/bin' $checks = {} $config_defaults = {} diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index ec02b46e..42ebdf3e 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -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' }} @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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