From abb5bfdc4a18ce64568ccfef5cb3871553f1ce69 Mon Sep 17 00:00:00 2001 From: Daniel Hopper Date: Tue, 8 Dec 2015 13:11:44 -0500 Subject: [PATCH 1/3] Updating staging file download to use the binary version and create a symlink to the artifact for allowing new version installations --- manifests/install.pp | 25 ++++++++++++++++--------- spec/classes/init_spec.rb | 6 +++--- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index d3f9691b..fdd4e518 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -15,17 +15,24 @@ case $consul::install_method { 'url': { - staging::file { 'consul.zip': - source => $consul::real_download_url + 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, + target => "${::staging::path}/consul-${consul::version}/consul"; } if ($consul::ui_dir and $consul::data_dir) { diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 239a1af4..1608ecdb 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -84,21 +84,21 @@ 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') } 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') } 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') } end From 02930926a424e85376d658601448b381fc1d3dfc Mon Sep 17 00:00:00 2001 From: Daniel Hopper Date: Wed, 9 Dec 2015 11:16:05 -0500 Subject: [PATCH 2/3] Adding notify of service to symlink to restart if configured to on upgrade/downgrade --- manifests/install.pp | 1 + spec/classes/init_spec.rb | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/manifests/install.pp b/manifests/install.pp index fdd4e518..e1c66c16 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -32,6 +32,7 @@ mode => '0555'; "${consul::bin_dir}/consul": ensure => link, + notify => $consul::notify_service, target => "${::staging::path}/consul-${consul::version}/consul"; } diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 1608ecdb..6988b266 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -85,6 +85,8 @@ context "When installing via URL by default" do 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 @@ -92,6 +94,7 @@ :version => '42', }} 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 @@ -99,6 +102,7 @@ :download_url => '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 From 944073fa5c79ec07eee27749487564badbc6d711 Mon Sep 17 00:00:00 2001 From: Daniel Hopper Date: Thu, 10 Dec 2015 10:05:51 -0500 Subject: [PATCH 3/3] Adding inclusion of staging module for url installations --- manifests/install.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/install.pp b/manifests/install.pp index e1c66c16..52314be4 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -15,6 +15,7 @@ case $consul::install_method { 'url': { + include staging staging::file { "consul-${consul::version}.${consul::download_extension}": source => $consul::real_download_url, } ->