On Friday, December 14, 2012 2:52:03 PM UTC-6, Jakov Sosic wrote: > > Hi. > > I am wondering why can't run stages get set inside the class? > > For example: > > class foo { > stage main > } >
A few answers from different perspectives: - Because the run stage in which a class should be applied isn't a characteristic of the class itself, but rather of how it is used - Potentially because Puppet wants to be able to determine a class's stage from its declaration - Because no 'stage' function has been implemented to do the job > > Because, if I want to use stages, I have to declare my class as > parametrized => so I can't use include or require anywhere else... > Aha! My own biggest objection to run stages, straight out of someone else's mouth! Honestly, I'm not all that enthusiastic about run stages generally -- I prefer ordinary resource relationships -- but stages do have their uses if you can get past the parametrized-style declaration thing. A PL employee once told me that he considered it a mistake that the parametrized class declaration syntax had been overloaded to carry not just data but metadata as well, such as 'stage'. I hope, therefore, that a different mechanism will be introduced at some point, but I have no insight into when that might happen. Perhaps there's a ticket for it, but I'm not motivated to look for one at the moment. > > I thought of a different approach, like: > > class foo_wrapper { > class{ 'foo': stage => 'somestage' } > } > > but would it work if I later include/require foo_wrapper in more than > one place? And is this code ok? > > It should be safe to include foo_wrapper multiple times, as long as none of the declarations (except possibly the first one parsed) use parametrized class syntax, and as long as nothing else declares class 'foo' directly. You may also find that you can declare ordinary relationships with Stage resources (I don't actually know, so if you test it then let us know). Even If so, that might or might not actually help. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/2w2UW5TNhjEJ. 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.