[Puppet Users] Re: Conditional host file entries, Puppet''s non-sequential tree

Larry Ludwig
Thu, 20 Aug 2009 13:18:21 -0000

On Aug 19, 2009, at 11:03 AM, Duncan Hill wrote:

>
> Hello folks,
>
> Running 0.24.6, and I need a clue-by-4 with something I''m trying
to
> do.
>
> I have a single manifest file, used by 3 servers.  Depending on the
> server name, I need to allocate a different set of variables that get
> used to populate a host {} block.
>
> Since Puppet doesn''t work in a top-down manner, this has a chance
of
> working sometimes, but not all the time.
>
> A convoluted approach that just came to mind is to use inheritance
> tricks.  Namely:
>
> node application-server inherits generic-server {
> all common stuff other than hosts
> possibly the if logic to set the IPs
> }
> node specific-1 inherits application-server {
> host {}
> }
> node specific-2 inherits application-server {
> host {}
> }
>
> Are there any better solutions to this?  I''m making the assumption
> (that I''m about to test) that inheritance is top-down.


Hi Duncan,

why not define the variables per ''node''?  Why use inheritance
at all?
Personally I''m not a fan of node inheritance and like putting all of
the classes in another class which then is in included in each node.

For your example, create a class and specify the ''host'' type.

If these are required parameters, you can put in your ''class''
something like this:

case $directadmin_cid {
       '''': { fail("You need to define your directadmin
cid! Please set
\$directadmin_cid in your site.pp or node config") }
}

This will make sure that the node has the proper variables when you
include the class.

Hope this helps...

-L

--
Larry Ludwig
Reductive Labs