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

Duncan Hill
Fri, 21 Aug 2009 14:03:58 -0000

2009/8/20 Larry Ludwig <larry@reductivelabs.com>:
>
>
> On Aug 19, 2009, at 11:03 AM, Duncan Hill wrote:
>
> 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.

I can do this, it just amplifies my work rather than reducing it.

The scenario is multiple stacks of ''identical'' servers -
Glassfish,
Tomcat, Postgres.  All of them have identical host files in terms of
names that are aliased to the IP addresses, it''s just the addresses
that change.  (Basically, umpteen development or QA environments in
VMware, all configured the same barring the IPs that the symbolic
names point to.)

So each node needs to define a set of IP addresses in variables, and I
just change the block of variables for each server, conditional on the
hostname, generating custom host addresses.  Well, that was the theory
at least.

I''ve tried the approach of

node foo {
 $ip1 = 1.1.1.1
 $ip2 = 2.2.2.2

 include host_definitions
}

class host_definitions {
 host {
  ''fred'': { ip => $ip1, alias => [ a, b, c ] }
 }
}

and more often than not I get an error that $ip1 isn''t defined, and
puppet falls over in a heap.

Inheritance has been useful for me, but I am actually moving a lot of
code over to class/module based (as and when I can; the current system
works, and I have enough keeping me busy that rewriting it isn''t high
on the list).

Cheers.