Hi. I am wondering why can''t run stages get set inside the class? For example: class foo { stage main } 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... 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? -- 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 12/14/2012 09:52 PM, Jakov Sosic wrote:> Hi. > > I am wondering why can''t run stages get set inside the class? > > For example: > > class foo { > stage main > } > > 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... > > 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? > >OK, so it seems that stuff work when I declare it like this: class foo { stage {''beforemain'': before => Stage[''main''] } } class foo::def::a { class { ''foo::classdef::a'': stage => ''beforemain'' } } class foo::def::b { class { ''foo::classdef::b'': stage => ''beforemain'' } } class foo::classdef::a { require foo::classdef::b } class foo::classdef::b { } I will try clean deploy of one of the systems to see if things break on runtime, but this is surely very complex way of avoiding what seems to be puppet limitation... It would be much easier if I could just set stage somehow without wrapper class and resource-like declaration... -- 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 There, I do a similar thing with my environment, I apply a class called "applysoe" to all nodes that is responsible for applying my modules and classes to nodes in a specific order as the ENC i use didn''t initially support it. Have you looked at the foreman ? The imminent release of 1.1 supports param classes, and it could be of use to you, there is a good video showing how these new actions work here: http://www.youtube.com/watch?v=Ksr0tilbmcc I havent tested it for run stages support however. Hope this is of some use. K On Friday, December 14, 2012 9:40:15 PM UTC, Jakov Sosic wrote:> > On 12/14/2012 09:52 PM, Jakov Sosic wrote: > > Hi. > > > > I am wondering why can''t run stages get set inside the class? > > > > For example: > > > > class foo { > > stage main > > } > > > > 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... > > > > 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? > > > > > > OK, so it seems that stuff work when I declare it like this: > > class foo { > stage {''beforemain'': before => Stage[''main''] } > } > > class foo::def::a { > class { ''foo::classdef::a'': stage => ''beforemain'' } > } > > class foo::def::b { > class { ''foo::classdef::b'': stage => ''beforemain'' } > } > > class foo::classdef::a { > require foo::classdef::b > } > > class foo::classdef::b { > } > > > > I will try clean deploy of one of the systems to see if things break on > runtime, but this is surely very complex way of avoiding what seems to > be puppet limitation... It would be much easier if I could just set > stage somehow without wrapper class and resource-like declaration... >-- 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/-/q5aK73M8hUAJ. 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 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 12/17/2012 03:44 PM, jcbollinger wrote:> * 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 usedYeah, that makes sense.> 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.My biggest concern is to set up repositories before main. Everything else uses ordinary relations and works 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.Yeah, I''ve already done the re-factoring of my code and everything works like a charm with wrapper classes.> 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.I don''t frankly need it, because I make relationships to wrapper classes... But I can test it if you want. -- 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.
This works (was added sometime during 2.6 cycle I think). class foo ($stage = main) { ... } include foo On Dec 14, 2012 9:52 PM, "Jakov Sosic" <jsosic@srce.hr> wrote:> Hi. > > I am wondering why can''t run stages get set inside the class? > > For example: > > class foo { > stage main > } > > 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... > > 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? > > > -- > 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.