On Sat, Jan 30, 2010 at 03:54:54PM -0800, mathie wrote:> I''m learning puppet and read the docs. My understanding is that
> classes are for generic services (singleton, need only once) while
> definitions are for repetitive calls (like functions). My question is
> say setting up a web server and ask the conf to listen to only a
> specific IP. Which should I use?
>
> class apache {
> file { "httpd.conf": content =>
template(''mywebserver.conf.erb'') }
> }
>
> Usage:
> $web_ip = "192.168.2.100"
> include apache
>
>
> or this?
>
> define fnApache($web_ip) {
> file { "httpd.conf": content =>
template(''mywebserver.conf.erb'') }
> }
>
> Usage: fnApache { "config-httpd": web_ip =>
''192.168.2.100'' }
>
> For me, the definition method is clearer (you see/know it is passing
> the param).
You are probably right to say that passing a parameter as a parameter,
rather than an appropriately scoped variable is more explicit. And this
might be enough argument to make the choice.
But in case you want more than instance of such server per node, then
the "set variable + include class" approach simply will not work. You
have to use a define. (But note that you will have to vary the ${name}s
of the resources in that case as well.)
regards,
--
Marcin Owsiany <marcin@owsiany.pl> http://marcin.owsiany.pl/
GnuPG: 1024D/60F41216 FE67 DA2D 0ACA FC5E 3F75 D6F6 3A0D 8AA0 60F4 1216
"Every program in development at MIT expands until it can read mail."
-- Unknown
--
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
http://groups.google.com/group/puppet-users?hl=en.