- From: Allan Wind <
>
- To:
- Subject: [chef] Re: What are you guys using dynamic resources for? (was: Notifying Resources within Ruby Block Resource)
- Date: Mon, 28 Nov 2011 20:53:44 -0500
On 2011-11-28 16:34:34, Daniel DeLeo wrote:
>
Questions about creating and using resources defined via ruby
>
blocks comes up often enough that I think it's worthwhile to
>
find a more elegant solution, if possible. Can you guys explain
>
what it is you're commonly doing with these?
>
>
Off the top of my head, I can see two sorts of scenarios:
>
1. You need to set a value on a resource during the convergence phase of
>
the Chef run (why?). Adding a means to have lazily evaluated values would
>
be a pretty easy fix.
>
2. You need to create multiple resources during converge based on some
>
state created by prior actions in the converge phase (again, why?). An
>
elegant solution to this would require a lot more thought.
One concrete case for me was a munin (resource monitoring tool)
cookbook. When you install the munin-node package it will
configure a number plugins using a combination of static and
auto-discovery. In any case I want to control the exact list of
plugins using my a cookbook.
Adding plugins could be done as usual by defining a set of
symlink links from /etc/munin/plugins to where all the available
plugins are installed. The destination directory depends on
platform so you either configure that ahead of time, or detect it
a run-time and use dynamically defined resources.
Removing plugins, on the other hand, can only be done at run-time
when you know what actual plugins were configured. Even if you
looked at the munin-node package to find out all the available
plugins and "blacklist" the ones you do not want (with associated
maintenance as packages change). munin has something they call
wildcard plugins which tags on a suffix of the symbolic link (for
example the name of a network interface).
What I end up doing in the cookbook is diffing the list of
plugins that I want to install (defined in an attribute) with the
ones currently installed, then add or delete the symbolic links
as needed. I do want to use chef resources to mange the links.
I am by no means an expert at this so it could be that I am
missing an obvious better way.
/Allan
--
Allan Wind
Life Integrity, LLC
<
http://lifeintegrity.com>
Archive powered by MHonArc 2.6.16.