[chef] Re: How to tell if Chef is running?


Chronological Thread 
  • From: Charles Duffy < >
  • To:
  • Subject: [chef] Re: How to tell if Chef is running?
  • Date: Mon, 24 Jan 2011 00:05:24 -0600

On Sun, Jan 23, 2011 at 11:54 PM, Noah Gibbs < "> > wrote:
Is there a standard way to tell if your (ruby) code is being invoked (indirectly) by a Chef run?  In this specific case the code is executing in a RubyGems pre-install hook.

Well, there's always the log resource.

Semi-relatedly, Chef seems strongly aimed at being run to configure the machine, and then mostly not run again on the same node except to add more software.  For example, there aren't a lot of uninstall-based resources, I don't see an obvious way to "reverse" a cookbook, few cookbooks seem written to work incrementally or in stages, etc.  Is that pretty much how it's intended, or am I missing something?

Things which are meant to be uninstallable should be written as resource providers with alternate actions. The LWRP mechanism makes this straightforward.

That said -- cookbooks work incrementally as a matter of course, by virtue of the resource providers they're built from being (where possible) idempotent in their actions. The "install this package" providers do nothing if the package is already there, the "fill out this file from this template" does nothing (and generates no notification-type events) if the file already has the desired contents, etc. 

On the occasions where I want some magic -- such that removing role $foo from a node will cause all the software installed by role $foo to be removed, for instance -- I've had to roll my own thus far. The same is true with Puppet; the only provisioning system I've seen which made that kind of thing easy was one I wrote myself at a former employer half a decade ago, and which I have no intent of ever resurrecting.



Archive powered by MHonArc 2.6.16.

§