I would like to install apache maven by using puppet recipe, but I can not find anywhere an example on how to do this. Can someone help with this? Apache maven is packed as tar.gz file. I am using a stand-alone setup for puppet.
Asked
Active
Viewed 6,822 times
2 Answers
11
I use this snippet from example42:
define netinstall (
$url,
$extracted_dir,
$destination_dir,
$owner = "root",
$group = "root",
$work_dir = "/var/tmp",
$extract_command = "tar -zxvf",
$preextract_command = "",
$postextract_command = ""
) {
$source_filename = urlfilename($url)
if $preextract_command {
exec {
"PreExtract $source_filename":
command => $preextract_command,
before => Exec["Extract $source_filename"],
refreshonly => true,
}
}
exec {
"Retrieve $url":
cwd => "$work_dir",
command => "wget $url",
creates => "$work_dir/$source_filename",
timeout => 3600,
}
exec {
"Extract $source_filename":
command => "mkdir -p $destination_dir && cd $destination_dir && $extract_command $work_dir/$source_filename",
unless => "find $destination_dir | grep $extracted_dir",
creates => "${destination_dir}/${extracted_dir}",
require => Exec["Retrieve $url"],
}
if $postextract_command {
exec {
"PostExtract $source_filename":
command => $postextract_command,
cwd => "$destination_dir/$extracted_dir",
subscribe => Exec["Extract $source_filename"],
refreshonly => true,
timeout => 3600,
require => Exec["Retrieve $url"],
}
}
}
example usage:
#Install prerequisites
exec { "VPSMonPrerequisites":
command => "yum install -y ${vpsmonitor::params::prerequisites}",
unless => "rpm -qi ${vpsmonitor::params::prerequisites}",
timeout => 3600,
}
#Install tgz from source url
netinstall { vpsmonitor:
url => "${vpsmonitor::params::source_url}",
extracted_dir => "${vpsmonitor::params::extracted_dir}",
destination_dir => "${vpsmonitor::params::destination_dir}",
postextract_command => "chown -R user. ${vpsmonitor::params::destination_dir}/${vpsmonitor::params::extracted_dir}",
require => [ Exec["VPSMonPrerequisites"], User["user"] ],
}

alexkb
- 3,216
- 2
- 30
- 30

Ger Apeldoorn
- 1,232
- 8
- 13
-
This example breaks on "urlfilename" for me. – Jared Jun 24 '14 at 17:33
-
I was able to get it working by just doing "puppet module install example42-puppi" and just using the second example as "puppi::netinstall" – Jared Jun 25 '14 at 18:01
0
There is a Puppet module that does this job for you: dsestero/download_uncompress
Example:
$phpstorm_version = '2017.2.1'
download_uncompress { 'PhpStorm':
download_base_url => 'https://download.jetbrains.com/webide',
distribution_name => "PhpStorm-${phpstorm_version}.tar.gz",
dest_folder => '/opt',
creates => "/opt/phpstorm-${phpstorm_version}",
uncompress => 'tar.gz',
}

Peterino
- 15,097
- 3
- 28
- 29