9
我想通過使用木偶配方來安裝apache maven,但我找不到任何地方如何做到這一點的例子。有人可以幫忙嗎? Apache maven打包爲tar.gz文件。我正在爲傀儡使用獨立設置。傀儡配方安裝tarball
我想通過使用木偶配方來安裝apache maven,但我找不到任何地方如何做到這一點的例子。有人可以幫忙嗎? Apache maven打包爲tar.gz文件。我正在爲傀儡使用獨立設置。傀儡配方安裝tarball
我用這個片段來自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"],
}
}
}
用法示例:
#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"] ],
}
有一個木偶模塊做這件工作對您:dsestero/download_uncompress
例子:
$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',
}
這個例子爲我打破了「urlfilename」。 – Jared
我能夠通過只做「puppet模塊安裝example42-puppi」並僅使用第二個示例作爲「puppi :: netinstall」 – Jared