Peter Valdemar Mørch
2012-Feb-14 15:05 UTC
[Puppet Users] exec: How to logoutput => on_failure and get STDERR too?
When a *nix command fails, it most often prints an error to STDERR:
capmon@peter:~> /bin/rm /nonexist
/bin/rm: cannot remove `/nonexist'': No such file or directory
exec''s logoutput => true doesn''t capture STDERR by default:
capmon@peter:~> puppet -e ''exec { e: command => "/bin/rm
/nonexist",
logoutput => true }''
err: /Stage[main]//Exec[e]/returns: change from notrun to 0 failed:
/bin/rm /nonexist returned 1 instead of one of [0] at line 1
Instead, it seems one needs to use the shell''s redirection for that:
capmon@peter:~> puppet -e ''exec { e: command => "/bin/rm
/nonexist
2>&1", logoutput => true }''
notice: /Stage[main]//Exec[e]/returns: /bin/rm: cannot remove
`/nonexist'': No such file or directory
err: /Stage[main]//Exec[e]/returns: change from notrun to 0 failed:
/bin/rm /nonexist 2>&1 returned 1 instead of one of [0] at line 1
Is there some way to always include STDERR in logoutput? It seems
brittle, shell dependent, non-portable and redundant to have to put
2>&1 at the end of all exec commands, so I''m hoping there is a
better
way...
Peter
--
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.
Felix Frank
2012-Feb-21 15:35 UTC
Re: [Puppet Users] exec: How to logoutput => on_failure and get STDERR too?
Hi, On 02/14/2012 04:05 PM, Peter Valdemar Mørch wrote:> It seems > brittle, shell dependent, non-portable and redundant to have to put > 2>&1 at the end of all exec commands, so I''m hoping there is a better > way...while I disagree as far as portability, dependability and savour are concerned ;-) I agree that it shouldn''t be needed. I suggest you file a bug report and link it here, so that interested parties can vote on it. Thanks! Cheers, Felix -- 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.
Stefan Schulte
2012-Feb-22 11:13 UTC
Re: [Puppet Users] exec: How to logoutput => on_failure and get STDERR too?
On Tue, Feb 14, 2012 at 04:05:22PM +0100, Peter Valdemar Mørch wrote:> When a *nix command fails, it most often prints an error to STDERR: > > capmon@peter:~> /bin/rm /nonexist > /bin/rm: cannot remove `/nonexist'': No such file or directory > > exec''s logoutput => true doesn''t capture STDERR by default: >What version of puppet are you using? This should have been fixed in 2.6.3 (http://projects.puppetlabs.com/issues/2359) -Stefan -- 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.