Hi I am trying to use nested classes but for whatever reason it doesn''t work. Here''s my site.pp file: include stdlib include apt node ''zenoss.example.com'' { include mock } class mock { class my_file { file { ''/tmp/test'': ensure => present, content => "Just testing to see if ''This'' is working", } } apt::source { "debian-squeeze": location => "http://ftp.jp.debian.org/debian/", release => "squeeze", repos => "main contrib non-free", include_src => false, } } The problem is when I run it, the apt repository is added but the file is not. What am I doing wrong? -- 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/-/XW0wKLEL1CgJ. 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.
i> I am trying to use nested classes but for whatever reason it doesn''t work. > Here''s my site.pp file: > > include stdlib > include apt > node ''zenoss.example.com'' { > include mock > } > class mock { > class my_file { > file { ''/tmp/test'': > ensure => present, > content => "Just testing to see if ''This'' is working", > } > } > apt::source { "debian-squeeze": > location => "http://ftp.jp.debian.org/debian/", > release => "squeeze", > repos => "main contrib non-free", > include_src => false, > } > } > > The problem is when I run it, the apt repository is added but the file is > not. What am I doing wrong? > > >Nested classes are not automatically included. Try including your nested class explicitly ,after apt:source: include my_file Alternatively, you don''t need to do that just for a file. Simply put your "file" resource directly within the "mock" class. I hope it helps. Best regards. -- 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.
It''s a bit deeper than that, Nesting a class definition inside of a class definition will result in a class namespaced as first_class::second_class. Because of this, you''ll need to "include mock::my_file" in your node declaration. It''s recommended to keep one class definition per file and to follow the Module patterns [2] and Style Guide [3] when doing so. [1] http://docs.puppetlabs.com/learning/modules1.html [2] http://docs.puppetlabs.com/guides/style_guide.html On Tue, Dec 4, 2012 at 7:10 PM, José Juan Montes <jjmontes@gmail.com> wrote:> i > >> I am trying to use nested classes but for whatever reason it doesn''t >> work. Here''s my site.pp file: >> >> include stdlib >> include apt >> node ''zenoss.example.com'' { >> include mock >> } >> class mock { >> class my_file { >> file { ''/tmp/test'': >> ensure => present, >> content => "Just testing to see if ''This'' is working", >> } >> } >> apt::source { "debian-squeeze": >> location => "http://ftp.jp.debian.org/debian/", >> release => "squeeze", >> repos => "main contrib non-free", >> include_src => false, >> } >> } >> >> The problem is when I run it, the apt repository is added but the file is >> not. What am I doing wrong? >> >> >> > Nested classes are not automatically included. > > Try including your nested class explicitly ,after apt:source: > > include my_file > > Alternatively, you don''t need to do that just for a file. Simply put your > "file" resource directly within the "mock" class. > > I hope it helps. Best regards. > > > > -- > 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. >-- Gary Larizza Professional Services Engineer Puppet Labs -- 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.
OK, that makes sense. Thanks for the tip. Gotta go do some reading. The thing is this very same manifest used to work under puppet 2.6. If there''s one thing I really don''t like about puppet it''s the amount of change although I understand it''s needed for a product under such heavy development. On 12/05/2012 11:21 AM, Gary Larizza wrote:> It''s a bit deeper than that, > > Nesting a class definition inside of a class definition will result in > a class namespaced as first_class::second_class. Because of this, > you''ll need to "include mock::my_file" in your node declaration. > > It''s recommended to keep one class definition per file and to follow > the Module patterns [2] and Style Guide [3] when doing so. > > [1] http://docs.puppetlabs.com/learning/modules1.html > [2] http://docs.puppetlabs.com/guides/style_guide.html > > > On Tue, Dec 4, 2012 at 7:10 PM, José Juan Montes <jjmontes@gmail.com > <mailto:jjmontes@gmail.com>> wrote: > > i > > I am trying to use nested classes but for whatever reason it > doesn''t work. Here''s my site.pp file: > > include stdlib > include apt > node ''zenoss.example.com <http://zenoss.example.com>'' { > include mock > } > class mock { > class my_file { > file { ''/tmp/test'': > ensure => present, > content => "Just testing to see if ''This'' is working", > } > } > apt::source { "debian-squeeze": > location => "http://ftp.jp.debian.org/debian/", > release => "squeeze", > repos => "main contrib non-free", > include_src => false, > } > } > > The problem is when I run it, the apt repository is added but > the file is not. What am I doing wrong? > > > Nested classes are not automatically included. > > Try including your nested class explicitly ,after apt:source: > > include my_file > > Alternatively, you don''t need to do that just for a file. Simply > put your "file" resource directly within the "mock" class. > > I hope it helps. Best regards. > > > > -- > 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 > <mailto:puppet-users@googlegroups.com>. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com > <mailto:puppet-users%2Bunsubscribe@googlegroups.com>. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > > > > > -- > > Gary Larizza > Professional Services Engineer > Puppet Labs > -- > 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 Tuesday, December 4, 2012 9:21:53 PM UTC-6, Gary Larizza wrote:> > It''s a bit deeper than that, > > Nesting a class definition inside of a class definition will result in a > class namespaced as first_class::second_class. >That is, nesting will result *only* in a class *definition* namespaced as Gary describes. It does itself not cause the nested class to be assigned to those nodes to which its containing class is assigned.> Because of this, you''ll need to "include mock::my_file" in your node > declaration. >Or add that ''include'' statement in the body of class mock, after the nested class definition. That would produce exactly the result you expected. If you''re going to do that, however, then you should consider why you wanted a nested class in the first place.> > It''s recommended to keep one class definition per file and to follow the > Module patterns [2] and Style Guide [3] when doing so. > > [1] http://docs.puppetlabs.com/learning/modules1.html > [2] http://docs.puppetlabs.com/guides/style_guide.html > >Indeed so. To be a bit more blunt: don''t lexically nest classes. Nesting provides little more than namespacing, which you can get explicitly instead. Furthermore, nested classes may be missed by the autoloader, and also by humans. Class nesting is mostly pain for little, if any, gain. 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/-/_SW7exzdl-IJ. 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 Tuesday, December 4, 2012 9:25:04 PM UTC-6, Navid Paya wrote:> > OK, that makes sense. Thanks for the tip. Gotta go do some reading. The > thing is this very same manifest used to work under puppet 2.6. >No, I''m sure it didn''t. None of the relevant characteristics of Puppet have changed between 2.6 and 3.0. I don''t doubt that you have a real-world manifest that broke between 2.6 and 3.0, but it''s not because Puppet ever auto-included nested classes. If I were to take a wild guess, I''d say it''s far more likely that your failure is related to the removal of dynamic scoping (which was discussed a lot around here, and for which the entire Puppet 2.7 series produces deprecation warnings). You can see a full list of changes from the 2.x series to the 3.0 series in the Puppet 3 release notes: http://docs.puppetlabs.com/puppet/3/reference/release_notes.html. Honestly, there is very little in the backwards incompatibility list that pertains to the Puppet language, and all changes of that type involve features that were already deprecated in the previous release series. 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/-/2Sat3nPs7lkJ. 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.