- From: Adam Jacob <
>
- To: "<
>" <
>
- Subject: [chef] Re: Logging the output/result of an only_if command
- Date: Thu, 25 Oct 2012 21:34:26 +0000
- Accept-language: en-US
Perhaps wrap that logic up in a resource/provider, and use the improved exception handling code to do the right thing, in particular with the new document formatters in 10.14 and friends?
Adam
On Oct 25, 2012, at 12:58 PM, Ian Marlier <
">
> wrote:
Hi, Chefs --
I have a few files on which I do syntax checks after Chef has generated the content, but before putting them into place. For example, my sudoers files are dynamically generated, but rather than write directly to /etc/sudoers, I first write to a temp location.
Then, in the stanza that actually writes to /etc/sudoers, I include 'only_if "/usr/sbin/visudo -c /tmp/sudoers"'
This works fine, and has saved me from a few issues. However, it doesn't really do anything useful in terms of telling me why the new file isn't being written to the correct place. In an ideal world, I'd like to be able to log either the output of the only_if
command, or just the fact that it returned a non-zero error code and what that return code was. However, I'm sort of at a loss when it comes to combining a system command and a Chef::Log stanza, conditional on the output of that system command.
Does anyone have any thoughts on how to do this?
Thanks!
- Ian
--
Ian Marlier | Manager of Platform Operations
Brightcove, Inc.
|
Archive powered by MHonArc 2.6.16.