[Puppet Users] reusing variables "best practices"

Gareth Allen
Thu, 03 Feb 2011 21:55:52 -0000

Hi All,

I''m in the process of creating Puppet modules for my load balanced
environment.  I have multiple Apache nodes behind a load balancer and each
Apache virtual host has its own internal IP.  I''ve created an Apache
module
that does this by creating an Apache vhost template and define my own
variables that are substituted by variables I''ve defined in my nodes
configuration. E.g.

apache1 node.pp:
$ip_www = 10.0.0.1
$ip_www2  10.0.0.1

apache2 node.pp:
$ip_www = 10.0.0.1
$ip_www2  10.0.0.1

apache vhost template:
<VirtualHost <%= ip_www %>:80>

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.

Thanks,
Gareth

--
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