Re: [Puppet Users] reusing variables "best practices"

Felix Frank
Tue, 08 Feb 2011 09:08:29 -0000

> The next step is to configure Piranha using Puppet.  The module creates
> a template using the IP''s defined in my node configuration.  In
order to
> use the IP''s I''ve defined in the nodes config file for
the piranha
> configuration I''d need to rename the variables to something like:
>
> $apache1_ip_www = 10.0.0.2
> $apache1_ip_www2  10.0.0.2
>
> As you can see if change the variable names to reflect the node name
> then the Apache vhost template will not be generated correctly.
>
> My question is what is the "best practise" when doing something
like
> this?  I was thinking of creating a new file for each apache node and
> write an "if" statement to include the appropriate file.  Another
option
> would be to put a case statement in the Apache module that if, for
> example, the nodes name is apache2 then set $ip_www as $apache1_ip_www.
> The part that I''m "concerned about" is how to redefine
variables to make
> them compatible with both modules and perhaps future modules.  I hope
> this all makes sense.

Not really ;-)

Do I read this correctly? You have two templates that are not generally
related, but rely on the same basic facts (i.e., a per-node IP-address
dedicated to Apache instances)?

What I''d do is (very near the definition of your "new"
template)

$apache1_ip_www = $ip_www
$apache1_ip_www2 = $ip_www2

By the way, have you checked whether the $ipaddress fact produces the
correct address for you? Because it would be several orders of magnitude
cleaner, more readable and more maintainable than inventing your custom
variables. You may even want to add a custom fact instead, if 10.0.0.2
is in fact not the primary address of your node.

HTH,
Felix

--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at