I do have a really strange issue with exec a tar command with puppet 2.6.0. If I run it with puppetmasterd I get the following error message: (//my.domain.net//Stage[main]/Workerzone/Build::Install[top]/ Exec[extract-top]/returns) change from notrun to 0 failed: /bin/bash - c ''/usr/sbin/tar -xzvf /usr/local/src/top-3.7.tar.gz'' returned 1 instead of one of [0] at /etc/puppet/modules/build/manifests/init.pp: 58 If I run the code manually with ''puppetd -t --debug'' there are no errors. What am I doing wrong? Here is my code: # build::install { ''top'': # download => ''http://www.unixtop.org/dist/top-3.7.tar.gz'', # creates => ''/url/local/bin/top'', # } define build::install ($download, $creates, $pkg_folder='''', $pkg_format="tar", $pkg_extension="", $buildoptions="", $rm_build_folder=true) { if defined( Package[''build-essential''] ) { debug("build-essential already installed") } else { package { ''build-essential'': ensure => installed } } $filename = basename($download) $extension = $pkg_format ? { zip => ".zip", tar => ".tar.gz", bzip => ".tar.bz2", default => $pkg_extension, } $foldername = $pkg_folder ? { '''' => gsub($filename, $extension, ""), default => $pkg_folder, } $extractor = $pkg_format ? { zip => "/usr/bin/unzip -q -d /usr/local/src", bzip => "/usr/sbin/tar -xjf", default => "/usr/sbin/tar -xzf" , } # download is fine exec { "download-$name": cwd => "/usr/local/src", command => "/usr/bin/wget -q $download", timeout => 120, unless => "test -f $creates", } # here I always get an error exec { "extract-$name": cwd => "/usr/local/src", command => "$extractor /usr/local/src/$filename", timeout => 120, path => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/ sbin:/bin", require => Exec["download-$name"], } exec { "config-$name": cwd => "/usr/local/src/$foldername", command => "./configure $buildoptions", timeout => 120, require => Exec["extract-$name"], } exec { "make-install-$name": cwd => "/usr/local/src/$foldername", command => "/usr/bin/make && /usr/bin/make install", timeout => 600, require => Exec["config-$name"], } # remove build folder case $rm_build_folder { true: { notice("remove build folder") exec { "remove-$name-build-folder": command => "/usr/bin/rm -rf /usr/local/src/$foldername", require => Exec["make-install-$name"], } # exec } # true } # case } The code runs on a nexenta ncp 3.0 (SunOS) box. Any ideas? Thanks -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Check you environment path variable. Tar might not find something, most probably, the gzip executable (not 100% sure on this part). Usually if something doesn''t work in specific cases, but it works in you bash console, you can make a safe bet on environment variables and/or running user. Silviu On 14.09.2010 21:35, jerry wrote:> I do have a really strange issue with exec a tar command with puppet > 2.6.0. If I run it with puppetmasterd I get the following error > message: > > (//my.domain.net//Stage[main]/Workerzone/Build::Install[top]/ > Exec[extract-top]/returns) change from notrun to 0 failed: /bin/bash - > c ''/usr/sbin/tar -xzvf /usr/local/src/top-3.7.tar.gz'' returned 1 > instead of one of [0] at /etc/puppet/modules/build/manifests/init.pp: > 58 > > If I run the code manually with ''puppetd -t --debug'' there are no > errors. What am I doing wrong? Here is my code: > > # build::install { ''top'': > # download => ''http://www.unixtop.org/dist/top-3.7.tar.gz'', > # creates => ''/url/local/bin/top'', > # } > > define build::install ($download, $creates, $pkg_folder='''', > $pkg_format="tar", $pkg_extension="", $buildoptions="", > $rm_build_folder=true) { > > if defined( Package[''build-essential''] ) { > debug("build-essential already installed") > } else { > package { ''build-essential'': ensure => installed } > } > > $filename = basename($download) > > $extension = $pkg_format ? { > zip => ".zip", > tar => ".tar.gz", > bzip => ".tar.bz2", > default => $pkg_extension, > } > > $foldername = $pkg_folder ? { > '''' => gsub($filename, $extension, ""), > default => $pkg_folder, > } > > $extractor = $pkg_format ? { > zip => "/usr/bin/unzip -q -d /usr/local/src", > bzip => "/usr/sbin/tar -xjf", > default => "/usr/sbin/tar -xzf" , > } > > # download is fine > exec { "download-$name": > cwd => "/usr/local/src", > command => "/usr/bin/wget -q $download", > timeout => 120, > unless => "test -f $creates", > } > > # here I always get an error > exec { "extract-$name": > cwd => "/usr/local/src", > command => "$extractor /usr/local/src/$filename", > timeout => 120, > path => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/ > sbin:/bin", > require => Exec["download-$name"], > } > > exec { "config-$name": > cwd => "/usr/local/src/$foldername", > command => "./configure $buildoptions", > timeout => 120, > require => Exec["extract-$name"], > } > > exec { "make-install-$name": > cwd => "/usr/local/src/$foldername", > command => "/usr/bin/make&& /usr/bin/make install", > timeout => 600, > require => Exec["config-$name"], > } > > # remove build folder > case $rm_build_folder { > true: { > notice("remove build folder") > exec { "remove-$name-build-folder": > command => "/usr/bin/rm -rf /usr/local/src/$foldername", > require => Exec["make-install-$name"], > } # exec > } # true > } # case > > } > > The code runs on a nexenta ncp 3.0 (SunOS) box. Any ideas? > > Thanks >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Thanks for your tip! Path is set early in base inheritance class to: Exec { path => "/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/ sbin:/sbin" } But even if I set this path env var in the exec block it fails: # here I always get an error exec { "extract-$name": cwd => "/usr/local/src", command => "$extractor /usr/local/src/$filename", timeout => 120, path => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/ sbin:/bin", require => Exec["download-$name"], } Adding: loglevel => verbose, logoutput => true, Doesn´t give any additional output. I´m a little loss with it... On 14 Sep., 22:45, Silviu Paragina <sil...@paragina.ro> wrote:> Check you environment path variable. Tar might not find something, > most probably, the gzip executable (not 100% sure on this part). Usually > if something doesn''t work in specific cases, but it works in you bash > console, you can make a safe bet on environment variables and/or running > user. > > Silviu-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Thanks Silviu, you was right, it is definitely a path problem with tar and puppet seems to ignore the path (?) I solved it by using gunzip and tar after another (piped): $unzip = "/usr/bin/unzip" $tar = "/usr/sbin/tar" $bunzip = "/usr/bin/bunzip2" $gunzip = "/usr/bin/gunzip" $extractor = $pkg_format ? { zip => "$unzip -q -d $cwd $cwd/$filename", bzip => "$bunzip -c $cwd/$filename | $tar -xf -", default => "$gunzip < $cwd/$filename | $tar -xf -" } exec { "extract-$name": cwd => "$cwd", command => "$extractor", timeout => 120, # 2 minutes require => Exec["download-$name"], } If anybody has a need for a build module, please feel free to download it from github: http://github.com/jfqd/puppet-module-build -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
> If anybody has a need for a build module, please feel free to download > it from github: > > http://github.com/jfqd/puppet-module-buildThanks, this was very useful! Maybe this deserves a new thread, but I don''t think some of the logic is working right. Maybe its a difference with 0.25.5, but all the execs "want" to be executed, and the download just doesn''t happen if the final build install target exists (which is an odd way of thinking about it too ... I could see not downloading if $cwd/$filename existed. Maybe in 2.6 (which I haven''t upgraded to) the unless resolving to false makes the require chain break? Anyhow, I both needed this working today and was feeling productive so I made some modifications, hope they are helpful, including: 0.25.5 compatible (switched some ruby stuff to puppet regsubst function), redo format/extension determining (code wouldn''t let you have a custom extension .myunusualtarball if you had defined pkg_format to be a known type) and allow extensionless files, added "zip0" format for zip files that don''t have an initial nested directory (this "feature" untested!!), tarballs without configure now scripts work, and the whole thing is idempotent using notify/subscribe so you don''t need wrapper logic, the reinstall will only happen if filename/basename in the URL changes (i.e. version) or the $creates target doesn''t exist. Oh, and since I''m on a different platform (CentOS) and I didn''t want to change the command variables in such a way that it broke for you people that have tar in /usr/sbin (strange place to have it...), I ended up using "path" attributes instead. So I guess this *is* relevant to the original post after all! ;-) http://pastie.org/1241991 Eric -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.