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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to