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.
Hi, I believe that you can only do this in the node definition - though the documentation doesn''t specifically say this. Cheers, Den On 07/04/2011, at 16:49, Jens Bräuer <jens.braeuer@numberfour.eu> wrote:> 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.-- 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.
On Apr 7, 1:49 am, Jens Bräuer <jens.brae...@numberfour.eu> wrote:> 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 herehttps://github.com/jordansissel/puppet-examples/blob/master/nodeless-..., 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.It''s not obvious to me why your example fails. Perhaps the client log showing the actual error message and its context would help, especially if debug-level logging were enabled. On the other hand, I''m not a big fan a parameterized classes. There are good use cases for them, but I think they are the wrong tool for most jobs. I would write your particular example without them, but also without class inheritence: class haproxy { if has_role("loadbalancer") { $conf = "puppet://modules/haproxy/conf1" } else { $conf = "puppet://modules/haproxy/conf2" } } # ... include ''haproxy'' ###### Many uses of parameterized classes can be rewritten in a similar way to use unparameterized ones, simply by pushing the parameter selection logic down into the class. That''s especially suitable where the parameter logic is based on relatively generic facts (e.g. roles), rather than on highly node-specific ones (such as hostnames). John -- 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.