Ben Lavender
2011-Jan-30 16:19 UTC
[Puppet Users] Run stages implicitly include classes, is this behavior intended?
So I am using a mix of old puppet and the Ruby DSL on a new project (loving it, new as it is!). But I''ve run into some behavior that surprised me. In my default node, (.pp), I have, among others, these lines: node "default" { class { ''amqp'': stage => system } include roles } (It seems that with the current Ruby DSL, the stage assignment must happen, in a .pp file, after the ''amqp'' class has been imported from elsewhere). In roles.rb, I have, among others, these lines: hostclass ''roles'' do roles = scope.lookupvar(''ec2_security_groups'').split('':'').map {|s| s.gsub(/-/,''_'') }.map(&:to_sym) include ''amqp'' if roles.include? :amqp end What surprised me is that my clever plan to do some fun logic on system roles is thwarted by the stage assignment. Regardless of whether or not I include the amqp class anywhere else, the stage assignment includes the class in the configuration. I did not expect this--I imagined that stage assignment was metadata, not assigning the class as a requirement for the stage. Is that intended behavior? Woefully, if my role logic is in a .rb file, I can''t even do the stage assignment conditionally, because of the aforementioned (surely temporary) limitations in stage assignments from the Ruby DSL. Am I missing something? If not, can someone suggest a workaround? Thanks, Ben -- 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.
Daniel Pittman
2011-Jan-31 17:25 UTC
Re: [Puppet Users] Run stages implicitly include classes, is this behavior intended?
On Jan 30, 2011 8:19 AM, "Ben Lavender" <blavender@gmail.com> wrote:> > So I am using a mix of old puppet and the Ruby DSL on a new project > (loving it, new as it is!). But I''ve run into some behavior that > surprised me. > > In my default node, (.pp), I have, among others, these lines: > > node "default" { > class { ''amqp'': stage => system } > include roles > }[…]> What surprised me is that my clever plan to do some fun logic on > system roles is thwarted by the stage assignment. Regardless of > whether or not I include the amqp class anywhere else, the stage > assignment includes the class in the configuration. I did not expect > this--I imagined that stage assignment was metadata, not assigning the > class as a requirement for the stage. Is that intended behavior?Yes: the class statement in the equivalent of "include", as well as assigning that metadata. Regards, Daniel -- Puppet Labs Developer –http://puppetlabs.com Daniel Pittman <daniel@puppetlabs.com> Contact me via gtalk, email, or phone: +1 (877) 575-9775 Sent from a mobile device. Please forgive me if this is briefer than usual. -- 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.
Felix Frank
2011-Feb-02 13:57 UTC
Re: [Puppet Users] Run stages implicitly include classes, is this behavior intended?
> Yes: the class statement in the equivalent of "include", as well as > assigning that metadata....the workaround being: Use class instead of include in your ruby manifest (is this available?) and select the desired stage right there. Otherwise, define a wrapper-class that sets the stage for your amqp and include the wrapper class from roles. 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.
Ben Lavender
2011-Feb-02 15:55 UTC
Re: [Puppet Users] Run stages implicitly include classes, is this behavior intended?
On Wed, Feb 2, 2011 at 2:57 PM, Felix Frank <felix.frank@alumni.tu-berlin.de> wrote:>> Yes: the class statement in the equivalent of "include", as well as >> assigning that metadata. > > ...the workaround being: Use class instead of include in your ruby > manifest (is this available?) and select the desired stage right there.It''s not yet available in the Ruby DSL, unfortunately. It throws an error about the class already existing (example not from amqp:) Duplicate definition: Class[Redis::Main] is already defined at /etc/puppet/manifests/nodes.pp:20 on node puppet (the line number is the puppet file including the ruby file).> Otherwise, define a wrapper-class that sets the stage for your amqp and > include the wrapper class from roles.I guess that works, but what a mess--it''s a .pp file for each .rb file. It''ll work for now, though. Thanks.> 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.