download_uncompress
Version information
This version is compatible with:
- Puppet Enterprise 2023.8.x, 2023.7.x, 2023.6.x, 2023.5.x, 2023.4.x, 2023.3.x, 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x, 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x, 2017.3.x, 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
- Puppet >= 4.0.0
- Ubuntu, Debian, RedHat, CentOS
Start using this module
Add this module to your Puppetfile:
mod 'dsestero-download_uncompress', '1.5.1'
Learn more about managing modules with a PuppetfileDocumentation
#download_uncompress
####Table of Contents
- Overview
- Module Description - What the module does and why it is useful
- Setup - The basics of getting started with download_uncompress
- Usage - Configuration options and additional functionality
- Reference - An under-the-hood peek at what the module is doing and how
- Limitations - OS compatibility, etc.
- Development - Guide for contributing to the module
##Overview
This is the download_uncompress module. It allows to download and uncompress a software distribution in a specified directory.
##Module Description
The module provides a utility define that takes care to download and uncompress a software distribution in a specified directory. The software distribution can be uncompressed with unzip or untar or leaved as it is. The operations are performed only if the expected file or folder does not yet exists.
##Setup
###What download_uncompress affects
The module installs the unzip
package if it is not installed using stdlib ensure_packages
type.
The module performs a wget from the specified url into the /tmp
directory and possibly unzip the downloaded file into the destination folder. The base_url from which to download can be provided as a parameter and defaults to the value of the key distributions_base_url
defined in hiera.
###Setup Requirements
This modules requires the following other modules to be installed:
-
puppetlabs/stdlib
to use the
ensure_packages
resource.
###Beginning with download_uncompress
To download and unzip SoftwareXY.zip from the base url specified by the key distributions_base_url
defined in hiera, it is possible to use a declaration as the following:
download_uncompress {'dwnl_inst_swxy':
download_base_url => 'http://jee.invallee.it/dist',
distribution_name => 'SoftwareXY.zip'
dest_folder => '/tmp',
creates => '/tmp/SXYInstallFolder',
uncompress => 'tar.gz',
}
##Usage
It is convenient to specify via hiera the default base url to be used to download software distributions; typically it would be some kind of internal repository where software binary packages are made available. An example hiera (JSON) declaration would be as follows:
{
"distributions_base_url" : "http://site.x.y/dist"
}
Then, a typical declaration would be:
download_uncompress { 'install_jboss_5':
distribution_name => 'jboss-5.1.0.GA-jdk6.zip',
dest_folder => '/opt',
creates => '/opt/jboss-5.1.0.GA',
uncompress => 'zip',
user => jboss,
group => jboss,
}
Alternatively, the base url can be given as a parameter:
download_uncompress { 'install_jboss-4.2.3.GA':
download_base_url => 'http://sourceforge.net/projects/jboss/files/JBoss',
distribution_name => "JBoss-4.2.3.GA/jboss-4.2.3-jdk6.zip/download",
dest_folder => '/opt',
creates => '/opt/jboss-4.2.3.GA',
uncompress => 'zip',
user => jboss,
group => jboss,
}
Or, the full url can be specified in one place:
download_uncompress { 'install_jboss-4.2.3.GA':
distribution_name => 'http://sourceforge.nt/projects/jboss/files/JBoss/JBoss-4.2.3.GA/jboss-4.2.3-jdk6.zip/download',
dest_folder => '/opt',
creates => '/opt/jboss-4.2.3.GA',
uncompress => 'zip',
user => jboss,
group => jboss,
}
Another example, to put in place a JBoss library (no uncompression in this case):
download_uncompress { "${postgresqlModulePath}/postgresql-9.1-903.jdbc4.jar":
distribution_name => 'lib/postgresql-9.1-903.jdbc4.jar',
dest_folder => "${postgresqlModulePath}",
creates => "${postgresqlModulePath}/postgresql-9.1-903.jdbc4.jar",
user => jboss,
group => jboss,
}
##Development
If you need some feature please send me a (pull) request or send me an email at: dsestero 'at' gmail 'dot' com.
Reference
Table of Contents
Defined types
download_uncompress
: Downloads and possibly uncompress a file from a given url to a specified destination folder.
Defined types
download_uncompress
Downloads and possibly uncompress a file from a given url to a specified destination folder.
Examples
Declaring in manifest
download_uncompress {'dwnl_inst_swxy':
download_base_url => 'http://jee.invallee.it/dist',
distribution_name => 'SoftwareXY.zip',
dest_folder => '/tmp',
creates => '/tmp/SXYInstallFolder',
uncompress => 'tar.gz',
}
Parameters
The following parameters are available in the download_uncompress
defined type.
download_base_url
Data type: Optional[String]
base URL from which to download. Defaults to distributions_base_url key defined in hiera or undef if such key is not found.
Default value: lookup('distributions_base_url', String, 'first', undef)
distribution_name
Data type: String
name of the distribution to download or full URL, in which case the parameter $download_base_url is ignored.
dest_folder
Data type: String
destination folder where to unzip (or possibly only download) the distribution.
creates
Data type: Optional[String]
folder created after downloading and possibly unzipping, useful to make the resource type idempotent. Defaults to undef in which case the parameter +refreshonly+ better would be true.
Default value: undef
uncompress
Data type: Enum['none', 'zip', 'tar.gz', 'jar']
compression type used by the distribution or +none+ if no uncompression is needed. Defaults to +none+.
Default value: 'none'
user
Data type: String
user to be used when performing the download and the eventual uncompression. Defaults to +root+.
Default value: root
group
Data type: String
group to be used when performing the download and the eventual uncompression. Defaults to +root+.
Default value: root
wget_options
Data type: String
options to pass to the wget command. Defaults to the empty string.
Default value: ''
install_unzip
Data type: Boolean
whether to install the package unzip if missing. Defaults to +true+.
Default value: true
refreshonly
Data type: Boolean
Boolean if set to true, the exec performing download and uncompress tasks will only run when download_uncompress receives an event. Defaults to +false+.
Default value: false
##2018-11-20 - Release - 1.5.1 ###Summary Fixed regression: syntax error introduced in 1.5.0 ##2018-11-19 - Release - 1.5.0 ###Summary Added the parameter refreshonly to the exec performing the actual job in order to allow to do it only when download_uncompress receives an event.
##2018-05-28 - Release - 1.4.2 ###Summary Replaced the use of hiera with lookup function to retrieve base url from hiera data. Updated to pdk template 1.5.0
##2018-03-15 - Release - 1.4.1 ###Summary Fixed README that was still mentioning a removed private class.
##2018-03-15 - Release - 1.4.0 ###Summary Updated to Puppet 4+ and added type validation.
Enabled use of PDK (Puppet Development Kit).
Documented using puppet strings.
Other minor fixes and polishing.
##2018-03-09 - Release - 1.3.3 ###Summary The ensure_packages function from stdlib is invoked directly rather than through dependencies class in order to prevent class duplication when the define is used multiple times.
##2017-09-20 - Release - 1.3.2 ###Summary Added option to choose whether to install unzip or not. Note that the install_unzip parameter is supported both in Puppet 3 and 4/5.
##2016-07-12 - Release - 1.3.1 ###Summary Added Debian, RedHat and CentOS distributions as supported. Removed restriction on specific Ubuntu versions.
##2016-07-12 - Release - 1.3.0 ###Summary Added capability to uncompress jar file by using the unzip command. Added -o option to unzip in order to overwrite existing files. Added optional parameter to allow passing specific options to the wget command.
##2015-08-25 - Release - 1.2.0 ###Summary Introduces dependency from stdlib in order to make use of ensure_packages to ensure package unzip is installed. Furthermore, specifies the path where to search for the commands used (no more error in case they are not set as global defaults in the site.pp).
##2015-06-8 - Release - 1.1.1
###Summary
Fix the fact the hiera key distributions_base_url
is optional when download_base_url
is specified or distribution_name
begins with http://
.
A Puppet error is raised if none of these conditions is satisfied.
##2015-06-8 - Release - 1.1.0
###Summary
Allow to specify full URL as distribution_name
in which case the parameter download_base_url
is ignored.
##2015-04-30 - Release - 1.0.3 ###Summary Improved documentation, rspec tests added, license changed from CC-BY-SA-4.0 to Apache-2.0.
##2015-04-27 - Release - 1.0.2 ###Summary Code polishing to be more compliant with puppet-lint suggestions.
####Bugfixes Corrected dependency name.
##2015-04-22 - Release - 1.0.1 ###Summary Code polishing to be more compliant with puppet-lint suggestions.
##2015-04-21 - Release - 1.0.0 ###Summary Initial release as PuppetForge module.
####Features See the README.markdown
####Bugfixes
####Known bugs
- No known bugs
Dependencies
- puppetlabs/stdlib (4.x)
Copyright (C) 2015 Dario Sestero Dario Sestero can be contacted at: dsestero 'at' gmail 'dot' com Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.