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
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
What version of puppet are you using? This should have been fixed in
2.6.3 (http://projects.puppetlabs.com/issues/2359)
-Stefan