On Tue, 07 Jun 2011 10:29:12 -0500, Jennings, Jared L CTR USAF AFMC 46 SK/CCI 
wrote:
> 
> Helwig:
> > Unfortunately, the documentation is just plain wrong.  loglevel is the
> > only one that supports "any legal log level".  logoutput really does
> > only support true, false, and on_failure.
> > 
> > Is pwck exiting non-zero when there is output?  That should be
> > sufficient to trigger the behavior it seems like you're looking for if
> > you have 'logoutput => on_failure' in the exec.
> 
> pwck indeed behaves nicely with its exitcodes - the problem is I want
> the output to be an err, not a notice:
> 
> notice: /Stage[main]/User::Valid/Exec[pwck]/returns: user 'foo':
> directory '/home/foo' does not exist
> notice: /Stage[main]/User::Valid/Exec[pwck]/returns: pwck: no changes
> err: /Stage[main]/User::Valid/Exec[pwck]/returns: change from notrun to
> 0 failed: /usr/sbin/pwck -r returned 2 instead of one of [0] at
> /etc/puppet/modules/user/manifests/valid.pp:11
> 
> If I set loglevel => err, that makes the output purple, but if pwck is
> happy, the loglevel setting also makes the "ran successfully" message an
> err.
> 

Hm...yeah, sorry.  I hadn't noticed that the actual output was notice,
and not err when the command fails.  I was just testing around with
echo, and setting "returns => 1" to get it to "fail", but I guess I just
wasn't looking closely enough.

You can kind of hack Puppet to do this now, but only if the command
you're running is purely checking things, and does not have any
side-effects.

  exec { 'pwck -r':
    path      => '/usr/bin:/bin:/usr/sbin:/sbin',
    logoutput => on_failure,
    loglevel  => err,
    unless    => 'pwck -r',
  }

By doing the "unless => 'pwck -r'", the resource won't even show up as
having been run if 'pwck -r' returns 0.  Having to run the command twice
is a hack, but it's the best I can think of at the moment.

Seems reasonable that when "logoutput => on_failure" the actual output
should be logged as an err, instead of a notice.  Would you mind filing
a feature request on the issue tracker[1]?

[1] http://projects.puppetlabs.com

-- 
Jacob Helwig

Attachment: signature.asc
Description: Digital signature

Reply via email to