On Sep 23, 9:36 am, Daniel Maher <d...@witbe.net> wrote:
> Hello,
>
> I have two sites with a small number of machines at each.  Each site is
> functionally identical.  I would like to set up a bunch of templates for
> the various services at each site, with a handful of variables that
> indicate which site the service is configured for.  What would be "best
> practice" way to accomplish this in Puppet ?
>
> Consider :
>
> s...@abc$ facter | grep domain
> domain => abc.dom.ain
> s...@abc$ cat /etc/resolv.conf
> search abc.dom.ain
> 10.1.0.1
>
> s...@xyz$ facter | grep domain
> domain => xyz.dom.ain
> s...@abc$ cat /etc/resolv.conf
> search xyz.dom.ain
> 10.2.0.1
>
> Thus i would like a template "resolv.conf.erb" :
>
> search <%= site_name =>.dom.ain
> 10.<%= site_ip =>.0.1
>
> I _could_ put something like this into _every_ class :
>
> $site_name = $domain ? {
>    'abc.dom.ain' => 'abc',
>    'xyz.dom.ain' => 'xyz',}
>
> # etc...
>
> That works, but frankly it's offensive in every way.  There are clearly
> other ways to go about it, so i am curious : for Puppet, what is the
> best practice solution ?
>
> Thank you all for your time and consideration.
>
> --
> Daniel Maher <dma AT witbe DOT net>
> "The Internet is completely over." -- Prince

I have code available that might work for you, since I manage
different sites as well as pre-production environments (as opposed to
puppet's internal understanding of environments) by grouping them
together by each site or POP[1]. Check out my site manifest[2]. It
references $pop which corresponds to your $site_name. The code to use
$pop is in the generic module[3].

It is preferable to have your variables listed in one place, like the
site manifest, than to use ::location which would scatter your
variables throughout your modules and lead to lots of code duplication
with respect to case statements.

-g

[1] - http://en.wikipedia.org/wiki/Point_of_Presence
[2] - http://github.com/ghoneycutt/puppet-sitemanifest/blob/master/site.pp
[3] - http://forge.puppetlabs.com/ghoneycutt/generic

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to