On Fri, May 20, 2011 at 5:26 AM, Bilco105 <bilco...@gmail.com> wrote:

> Hi,
>
> I'm defining a class whose responsibility is to setup an application
> folder, virtual host, init script and so forth for a rails
> application. The class is defined as follows:
>
> class rails($name, $environment)
>  ## Include General Software
>  require nginx
>  require mysql
>
>   ## Setup application directories
>  File { ["/home/$app", "/home/$app/app", "/home/$app/app/log", "/home/
> $app/app/tmp"]:
>    ensure => directory
>    owner => "root"
>    group => "dev"
>    mode => 4755
>  }
>
>  ## etc
> }
>
> Now, on our production servers, we have one application running, so we
> do:
>
> node "production.domain.com" {
>  class { rails: name => "application1", env => "production" }
> }
>
> This works fine, and sets up all the requirements for the application.
> However, our staging server runs multiple applications, so I want to
> do the following:
>
> node "staging.domain.com" {
>  class { rails: name => "application1", env => "production" }
>  class { rails: name => "application2", env => "production" }
>  class { rails: name => "application3", env => "production" }
> }
>
> Obviously this complains about duplicate definitions of the rails
> class, but the variables are different. How can I work around this? Or
> what is a better way to implement what I'm trying to do? without
> having to duplicate everything
>
>
Classes are singletons and you can only have one of them.

If you want to instantiate multiple instances, use a defined resource type
instead.

http://docs.puppetlabs.com/guides/language_guide.html#defined-resource-types





-- 
Nigel Kersten
Product, Puppet Labs
@nigelkersten

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to