define netinstall ($url,$extracted_dir,$destination_dir,$owner = "root",$group = "root",$work_dir = "/var/tmp",$extract_command = "tar -zxvf",$preextract_command = "",$postextract_command = ""# $postextract_command = "./configure ; make ; make install") {$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",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"],}}}
command => "mkdir -p $destination_dir && cd $destination_dir &&
$extract_command $work_dir/$source_filename",
Also consider
unless => "test -d ${destination_dir }/${extracted_dir}",
or even better
creates => "${destination_dir }/${extracted_dir}",
for the repetition guard.
--
vagn
On 07/12/2011 12:19 PM, Al @ Lab42 wrote:
> You might find this define useful (
> https://github.com/example42/puppet-modules/blob/master/common/manifests/defines/netinstall.pp
> ):
>
or as a general best practice you might want to build your own packages.
They're much easier to handle!
~pete
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk4dO2kACgkQbwltcAfKi3+5WQCfa35P0lZKGS8xYyitmfLt7Kiy
wUwAn0pnp4xscGeMNl3VA1Lo1xSygYh9
=ZGSf
-----END PGP SIGNATURE-----
--To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/EjT5lFqc31MJ.
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.