Skip to content
This repository was archived by the owner on May 14, 2021. It is now read-only.

Fixed prerequisites fuckup and some changes #28

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
2 changes: 1 addition & 1 deletion .gemfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
/metadata.json
/.project
8 changes: 0 additions & 8 deletions Modulefile

This file was deleted.

30 changes: 23 additions & 7 deletions manifests/extract.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,36 @@
$ensure = present,
$src_target = '/usr/src',
$root_dir = '',
$nested_dir = undef,
$extension = 'tar.gz',
$timeout = 120,
$strip_components = 0,
$exec_path = ['/usr/local/bin', '/usr/bin', '/bin']) {

if $root_dir != '' {
$extract_dir = "${target}/${root_dir}"
} else {
$extract_dir = "${target}/${name}"
}

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.gz|tgz|tar.xz|txz|tar.bz2|tbz|tbz2)/ {
fail('Param strip_components just allowed in combination with tar')
}

if $extension == 'zip' and $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}"
Expand All @@ -66,7 +82,7 @@
exec {"Unpack ${name}":
command => $unpack_command,
path => $exec_path,
creates => $extract_dir,
creates => $creates_dir,
timeout => $timeout
}
}
Expand Down
12 changes: 9 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -48,6 +47,7 @@
$digest_type = 'md5',
$timeout = 120,
$root_dir = '',
$nested_dir = undef,
$extension = 'tar.gz',
$src_target = '/usr/src',
$allow_insecure = false,
Expand All @@ -56,9 +56,14 @@
$username = undef,
$password = undef,
$proxy = undef,
$dependency_class = Class['archive::prerequisites'],
$exec_path = ['/usr/local/bin', '/usr/bin', '/bin']) {

# list of packages needed for download and extraction
$packages = [ 'curl', 'unzip', 'tar' ]

# install additional packages if missing
ensure_packages($packages)

archive::download {"${name}.${extension}":
ensure => $ensure,
url => $url,
Expand All @@ -73,7 +78,7 @@
username => $username,
password => $password,
proxy => $proxy,
require => $dependency_class,
require => Package[$packages],
exec_path => $exec_path,
}

Expand All @@ -82,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,
Expand Down
18 changes: 0 additions & 18 deletions manifests/prerequisites.pp

This file was deleted.

33 changes: 33 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}