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?
Ian Marlier | Manager of Platform Operations
290 Congress Street, 4th Floor, Boston, MA 02110