Hi all, i try to run a puppet-setup that is not based on hostnames, but facts i supply to facter. The idea is described here https://github.com/jordansissel/puppet-examples/blob/master/nodeless-puppet/README.rdoc, but a basic example would be ---- if has_role("loadbalancer") { include loadbalancer::service } else { # Otherwise, this machine is not a loadbalancer include loadbalancer::remove } ---- How am i able to bring this together with parameterized classes? For instance this will complain about redefinition of class ''haproxy''. --- class haproxy ($conf = "puppet:///modules/haproxy/proxy.conf") { } if has_role("loadbalancer") { class { ''haproxy'': conf => "puppet://modules/haproxy/conf1" } } else { class { ''haproxy'': conf => "puppet://modules/haproxy/conf2" } } --- How can i "import" parameterized classes? Is there a work-around? I am quiet new to puppet, so if i missed the obvious or google keywords, please point me to the right direction. Regards, Jens -- 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.
> How am i able to bring this together with parameterized classes? For > instance this will complain about redefinition of class ''haproxy''. > > --- > class haproxy ($conf = "puppet:///modules/haproxy/proxy.conf") { > } > > if has_role("loadbalancer") { > class { ''haproxy'': conf => "puppet://modules/haproxy/conf1" } > } else { > class { ''haproxy'': conf => "puppet://modules/haproxy/conf2" } > } > --- > > How can i "import" parameterized classes? Is there a work-around?Hi, most simple thing that comes to mind: class { ''haproxy'': conf => has_role("loadbalancer") ? { true => "puppet://modules/haproxy/conf1", false => "puppet://modules/haproxy/conf2", } } According to Best Practices, you should use a case statement instead, though, initialize a variable and use that as the parameter value. Whichever you prefer. 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 http://groups.google.com/group/puppet-users?hl=en.
Hi Felix, thanks for that hint. I missed the obvious ;-) (and learned a lot about the difference between classes and defines) Regards, Jens On 08.04.2011, at 09:04, Felix Frank wrote:>> How am i able to bring this together with parameterized classes? For >> instance this will complain about redefinition of class ''haproxy''. >> >> --- >> class haproxy ($conf = "puppet:///modules/haproxy/proxy.conf") { >> } >> >> if has_role("loadbalancer") { >> class { ''haproxy'': conf => "puppet://modules/haproxy/conf1" } >> } else { >> class { ''haproxy'': conf => "puppet://modules/haproxy/conf2" } >> } >> --- >> >> How can i "import" parameterized classes? Is there a work-around? > > Hi, most simple thing that comes to mind: > > class { ''haproxy'': > conf => has_role("loadbalancer") ? { > true => "puppet://modules/haproxy/conf1", > false => "puppet://modules/haproxy/conf2", > } > } > > According to Best Practices, you should use a case statement instead, > though, initialize a variable and use that as the parameter value. > > Whichever you prefer. > > 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 http://groups.google.com/group/puppet-users?hl=en. >-- 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.