From 9a7f1d0d00e17de7b25758be92e01831e70f8885 Mon Sep 17 00:00:00 2001 From: Johannes Graf Date: Wed, 22 Oct 2014 19:23:23 +0200 Subject: [PATCH 01/11] Fixed prerequisites fuckup and some changes --- .gemfile | 2 +- .gitignore | 1 - Modulefile | 8 -------- manifests/init.pp | 6 +++--- manifests/prerequisites.pp | 4 +--- metadata.json | 33 +++++++++++++++++++++++++++++++++ 6 files changed, 38 insertions(+), 16 deletions(-) delete mode 100644 Modulefile create mode 100644 metadata.json diff --git a/.gemfile b/.gemfile index c9713f0..45a6e84 100644 --- a/.gemfile +++ b/.gemfile @@ -1,5 +1,5 @@ source 'https://rubygems.org' -puppetversion = ENV.key?('PUPPET_VERSION') ? "#{ENV['PUPPET_VERSION']}" : ['~> 3.2.0'] +puppetversion = ENV.key?('PUPPET_VERSION') ? "#{ENV['PUPPET_VERSION']}" : ['~> 3.7.0'] gem 'puppet', puppetversion diff --git a/.gitignore b/.gitignore index 008b417..d8fe4fa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -/metadata.json /.project diff --git a/Modulefile b/Modulefile deleted file mode 100644 index ea4c0b0..0000000 --- a/Modulefile +++ /dev/null @@ -1,8 +0,0 @@ -name 'gini-archive' -version '0.2.0' -author 'Jochen Schalanda' -license 'Apache 2.0' -project_page 'https://github.com/gini/puppet-archive' -source 'https://github.com/gini/puppet-archive' -summary 'Puppet module to download and extract tar and zip archives' -description 'This module downloads archives (tar.{gz,bz2,xz} and zip) using curl and extracts them to a given directory.' diff --git a/manifests/init.pp b/manifests/init.pp index 948011b..14a38b4 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -20,7 +20,6 @@ # - *$username: set basic auth username # - *$password: set basic auth password # - *$proxy: HTTP proxy in the form of "hostname:port"; e.g. "myproxy:8080" -# - *$dependency_class: Puppet class which installs the required programs (curl, tar, unzip) # - *$exec_path: Path being searched for all Exec resources, default: ['/usr/local/bin', '/usr/bin', '/bin'] # # Example usage: @@ -56,9 +55,10 @@ $username = undef, $password = undef, $proxy = undef, - $dependency_class = Class['archive::prerequisites'], $exec_path = ['/usr/local/bin', '/usr/bin', '/bin']) { + class {'archive::prerequisites': } + archive::download {"${name}.${extension}": ensure => $ensure, url => $url, @@ -73,7 +73,7 @@ username => $username, password => $password, proxy => $proxy, - require => $dependency_class, + require => Class['archive::prerequisites'], exec_path => $exec_path, } diff --git a/manifests/prerequisites.pp b/manifests/prerequisites.pp index e7ca18a..4cd05ee 100644 --- a/manifests/prerequisites.pp +++ b/manifests/prerequisites.pp @@ -12,7 +12,5 @@ $packages = [ 'curl', 'unzip', 'tar', ] # install additional packages if missing - package { $packages: - ensure => installed, - } + ensure_packages($packages, {ensure => installed}) } diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..ba8425b --- /dev/null +++ b/metadata.json @@ -0,0 +1,33 @@ +{ + "name": "gini-archive", + "version": "0.2.0", + "author": "Jochen Schalanda", + "summary": "Puppet module to download and extract tar and zip archives", + "license": "Apache 2.0", + "source": "https://github.com/gini/puppet-archive", + "project_page": "https://github.com/gini/puppet-archive", + "issues_url": "https://github.com/gini/puppet-archive/issues", + "tags": [ + "tar", "curl", "unzip", "download", "extract", "archive" + ], + "operatingsystem_support": [ + { + "operatingsystem": "Debian", + "operatingsystemrelease": [ + "7.6" + ] + } + ], + "requirements": [ + { + "name": "puppet", + "version_requirement": "3.7" + } + ], + "dependencies": [ + { + "name": "puppetlabs-stdlib", + "version_requirement": ">= 4.0.0" + } + ] +} From cd8508761e53361a6b7ddde9a5f6a237eb1c1940 Mon Sep 17 00:00:00 2001 From: Johannes Graf Date: Thu, 23 Oct 2014 12:18:15 +0200 Subject: [PATCH 02/11] Some Fixes prerequisites.pp is not working as a class ... even puppet 3.7.1 is building a wrong dependency graph --- manifests/init.pp | 8 ++++++-- manifests/prerequisites.pp | 16 ---------------- 2 files changed, 6 insertions(+), 18 deletions(-) delete mode 100644 manifests/prerequisites.pp diff --git a/manifests/init.pp b/manifests/init.pp index 14a38b4..336672c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -57,7 +57,11 @@ $proxy = undef, $exec_path = ['/usr/local/bin', '/usr/bin', '/bin']) { - class {'archive::prerequisites': } + # list of packages needed for download and extraction + $packages = [ 'curl', 'unzip', 'tar', ] + + # install additional packages if missing + ensure_packages($packages, {ensure => installed}) archive::download {"${name}.${extension}": ensure => $ensure, @@ -73,7 +77,7 @@ username => $username, password => $password, proxy => $proxy, - require => Class['archive::prerequisites'], + require => Package[$packages], exec_path => $exec_path, } diff --git a/manifests/prerequisites.pp b/manifests/prerequisites.pp deleted file mode 100644 index 4cd05ee..0000000 --- a/manifests/prerequisites.pp +++ /dev/null @@ -1,16 +0,0 @@ -# == Class: prerequisites -# -# Ensure any required dependencies for archive download and extraction are present. -# -# Parameters: -# -# None -# -class archive::prerequisites { - - # list of packages needed for download and extraction - $packages = [ 'curl', 'unzip', 'tar', ] - - # install additional packages if missing - ensure_packages($packages, {ensure => installed}) -} From 52d446e5dd6ea82d3c833ebf94a3f2060feb7ad3 Mon Sep 17 00:00:00 2001 From: Lutz Bader Date: Tue, 28 Oct 2014 17:50:30 +0100 Subject: [PATCH 03/11] nested_dir for zip --- manifests/extract.pp | 18 +++++++++++++----- manifests/init.pp | 2 ++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/manifests/extract.pp b/manifests/extract.pp index fec7335..d8d8c96 100644 --- a/manifests/extract.pp +++ b/manifests/extract.pp @@ -32,15 +32,23 @@ $ensure = present, $src_target = '/usr/src', $root_dir = '', + $nested_dir = $name, $extension = 'tar.gz', $timeout = 120, $strip_components = 0, $exec_path = ['/usr/local/bin', '/usr/bin', '/bin']) { - - if $root_dir != '' { - $extract_dir = "${target}/${root_dir}" + + if $nested_dir { + $extract_dir = $target + $creates_dir = "${target}/${name}" } else { - $extract_dir = "${target}/${name}" + + if $root_dir != '' { + $extract_dir = "${target}/${root_dir}" + } else { + $extract_dir = "${target}/${name}" + } + $creates_dir = $extract_dir } case $ensure { @@ -66,7 +74,7 @@ exec {"Unpack ${name}": command => $unpack_command, path => $exec_path, - creates => $extract_dir, + creates => $creates_dir, timeout => $timeout } } diff --git a/manifests/init.pp b/manifests/init.pp index 336672c..d2d2f37 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -47,6 +47,7 @@ $digest_type = 'md5', $timeout = 120, $root_dir = '', + $nested_dir = $name, $extension = 'tar.gz', $src_target = '/usr/src', $allow_insecure = false, @@ -86,6 +87,7 @@ target => $target, src_target => $src_target, root_dir => $root_dir, + nested_dir => $nested_dir, extension => $extension, timeout => $timeout, strip_components => $strip_components, From 841773084313babf60c71cb9d6e2ffc936c613aa Mon Sep 17 00:00:00 2001 From: Johannes Graf Date: Tue, 28 Oct 2014 18:30:31 +0100 Subject: [PATCH 04/11] Moved nested_dir code into ensure => present case --- manifests/extract.pp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/manifests/extract.pp b/manifests/extract.pp index d8d8c96..b9bbbfb 100644 --- a/manifests/extract.pp +++ b/manifests/extract.pp @@ -37,23 +37,22 @@ $timeout = 120, $strip_components = 0, $exec_path = ['/usr/local/bin', '/usr/bin', '/bin']) { - - if $nested_dir { - $extract_dir = $target - $creates_dir = "${target}/${name}" - } else { - - if $root_dir != '' { - $extract_dir = "${target}/${root_dir}" - } else { - $extract_dir = "${target}/${name}" - } - $creates_dir = $extract_dir - } case $ensure { present: { + if $nested_dir { + $extract_dir = $target + $creates_dir = "${target}/${name}" + + } else { + if $root_dir != '' { + $extract_dir = "${target}/${root_dir}" + } else { + $extract_dir = "${target}/${name}" + } + $creates_dir = $extract_dir + } $extract_zip = "unzip -o ${src_target}/${name}.${extension} -d ${extract_dir}" $extract_targz = "tar --no-same-owner --no-same-permissions --strip-components=${strip_components} -xzf ${src_target}/${name}.${extension} -C ${extract_dir}" $extract_tarxz = "tar --no-same-owner --no-same-permissions --strip-components=${strip_components} -xJf ${src_target}/${name}.${extension} -C ${extract_dir}" From 25a6f1941965818fd9bb27a7171da632ae00fdb9 Mon Sep 17 00:00:00 2001 From: Johannes Graf Date: Tue, 28 Oct 2014 18:32:14 +0100 Subject: [PATCH 05/11] Added some checks --- manifests/extract.pp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/manifests/extract.pp b/manifests/extract.pp index b9bbbfb..c1e7439 100644 --- a/manifests/extract.pp +++ b/manifests/extract.pp @@ -41,6 +41,14 @@ case $ensure { present: { + if $extension != 'zip' and $nested_dir { + fail("Param nested_dir just allowed in combination with unzip") + } + + if $strip_components > 0 and $extension != 'tar' { + fail('Param strip_components just allowed in combination with tar') + } + if $nested_dir { $extract_dir = $target $creates_dir = "${target}/${name}" @@ -53,6 +61,7 @@ } $creates_dir = $extract_dir } + $extract_zip = "unzip -o ${src_target}/${name}.${extension} -d ${extract_dir}" $extract_targz = "tar --no-same-owner --no-same-permissions --strip-components=${strip_components} -xzf ${src_target}/${name}.${extension} -C ${extract_dir}" $extract_tarxz = "tar --no-same-owner --no-same-permissions --strip-components=${strip_components} -xJf ${src_target}/${name}.${extension} -C ${extract_dir}" From 3f1dde407bdd33c0c345ecd76adc545121735b41 Mon Sep 17 00:00:00 2001 From: lbdr Date: Thu, 30 Oct 2014 15:27:42 +0100 Subject: [PATCH 06/11] Update extract.pp --- manifests/extract.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/extract.pp b/manifests/extract.pp index c1e7439..4ac6f08 100644 --- a/manifests/extract.pp +++ b/manifests/extract.pp @@ -49,7 +49,7 @@ fail('Param strip_components just allowed in combination with tar') } - if $nested_dir { + if $extension == 'zip' and $nested_dir { $extract_dir = $target $creates_dir = "${target}/${name}" From f771b0d668011e931321196505330cbae3f3697a Mon Sep 17 00:00:00 2001 From: grafjo Date: Thu, 30 Oct 2014 15:48:56 +0100 Subject: [PATCH 07/11] Update extract.pp --- manifests/extract.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/extract.pp b/manifests/extract.pp index 4ac6f08..bc78825 100644 --- a/manifests/extract.pp +++ b/manifests/extract.pp @@ -32,7 +32,7 @@ $ensure = present, $src_target = '/usr/src', $root_dir = '', - $nested_dir = $name, + $nested_dir = undef, $extension = 'tar.gz', $timeout = 120, $strip_components = 0, From e6ff56c99bdebfa8b00be08ef02c8c2929dbef1a Mon Sep 17 00:00:00 2001 From: grafjo Date: Thu, 30 Oct 2014 17:08:31 +0100 Subject: [PATCH 08/11] Update init.pp --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index d2d2f37..8e083c1 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -47,7 +47,7 @@ $digest_type = 'md5', $timeout = 120, $root_dir = '', - $nested_dir = $name, + $nested_dir = undef, $extension = 'tar.gz', $src_target = '/usr/src', $allow_insecure = false, From 18187ebb3b603574eeeb66e6144dce8c1ff663a4 Mon Sep 17 00:00:00 2001 From: lbdr Date: Fri, 31 Oct 2014 11:14:09 +0100 Subject: [PATCH 09/11] Update extract.pp --- manifests/extract.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/extract.pp b/manifests/extract.pp index 4ac6f08..f0f842d 100644 --- a/manifests/extract.pp +++ b/manifests/extract.pp @@ -45,7 +45,7 @@ fail("Param nested_dir just allowed in combination with unzip") } - if $strip_components > 0 and $extension != 'tar' { + if $strip_components > 0 and $extension !~ /(tar.gz|tgz|tar.xz|txz|tar.bz2|tbz|tbz2)/ { fail('Param strip_components just allowed in combination with tar') } From 45340c315136555dc1a9b3edbb3aa71dfe2f59d0 Mon Sep 17 00:00:00 2001 From: Lutz Bader Date: Thu, 29 Jan 2015 16:06:22 +0100 Subject: [PATCH 10/11] Removed params from ensure_packages --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 8e083c1..f2e1f67 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -62,7 +62,7 @@ $packages = [ 'curl', 'unzip', 'tar', ] # install additional packages if missing - ensure_packages($packages, {ensure => installed}) + ensure_packages($packages) archive::download {"${name}.${extension}": ensure => $ensure, From 02d8ae2ccf781decd09d4b72177011fb6392b6d4 Mon Sep 17 00:00:00 2001 From: Lutz Bader Date: Thu, 29 Jan 2015 16:23:21 +0100 Subject: [PATCH 11/11] Fixing typo --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index f2e1f67..37a18f7 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -59,7 +59,7 @@ $exec_path = ['/usr/local/bin', '/usr/bin', '/bin']) { # list of packages needed for download and extraction - $packages = [ 'curl', 'unzip', 'tar', ] + $packages = [ 'curl', 'unzip', 'tar' ] # install additional packages if missing ensure_packages($packages)