Hello, I''m having some trouble with subclasses accessing other subclasses within the same main class. I have boiled it down a general case. I have the following files: ## /etc/puppet/modules/test1 class test1 { class {''test2::bar'':} } ## /etc/puppet/modules/test2/init.pp class test2 { class {test2::foo} class {test2::bar} class {test2::baz} } ## /etc/puppet/modules/test2/foo.pp class test2::foo { # do something here in foo } ## /etc/puppet/modules/test2/bar.pp class test2::bar { # do something here that requires test2::foo exec { ''bar_in_tmp'': path => ''/usr/bin:/usr/sbin:/bin'', command => "touch /tmp/bar", creates => ''/tmp/bar'', require => [ Class[''test2::foo''], ], } } ## /etc/puppet/modules/test2/baz.pp class test2::baz { # do something unwanted here } When the agent runs it dies saying "Could not find dependence Class[''Test2::Foo''] for Exec[''bar_in_tmp'']" Now if I change that line in test1 to just class {''test2'':} it runs without error. However since the main class call test2::baz, it does more than I wanted. Am I not understanding something? How do I just do bar and foo? Thanks in advance, -LTH -- 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/-/QJOSn1NqhEsJ. 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.
James Sweeny
2012-May-17 15:23 UTC
Re: [Puppet Users] Classes, Subclasses, and Requirements
You can''t require Class[''test2::foo''] unless it''s already available where you''re requiring it. You need to include test2::foo in test2::bar. On Thu, May 17, 2012 at 10:53 AM, LTH <ltharris@vcu.edu> wrote:> Hello, > > I''m having some trouble with subclasses accessing other subclasses within > the same main class. > > I have boiled it down a general case. I have the following files: > > ## /etc/puppet/modules/test1 > class test1 { > > class {''test2::bar'':} > > } > > ## /etc/puppet/modules/test2/init.pp > class test2 { > class {test2::foo} > class {test2::bar} > class {test2::baz} > } > > ## /etc/puppet/modules/test2/foo.pp > class test2::foo { > # do something here in foo > > } > > ## /etc/puppet/modules/test2/bar.pp > class test2::bar { > # do something here that requires test2::foo > exec { ''bar_in_tmp'': > path => ''/usr/bin:/usr/sbin:/bin'', > command => "touch /tmp/bar", > creates => ''/tmp/bar'', > require => [ > Class[''test2::foo''], > ], > } > > } > > ## /etc/puppet/modules/test2/baz.pp > > class test2::baz { > # do something unwanted here > > > } > > When the agent runs it dies saying "Could not find dependence > Class[''Test2::Foo''] for Exec[''bar_in_tmp'']" > > Now if I change that line in test1 to just class {''test2'':} it runs > without error. However since the main class call test2::baz, it does more > than I wanted. Am I not understanding something? How do I just do bar and > foo? > > Thanks in advance, > > -LTH > > > > > -- > 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/-/QJOSn1NqhEsJ. > 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. >-- James Sweeny Professional Services http://puppetlabs.com/ -- 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 Thursday, May 17, 2012 11:23:40 AM UTC-4, James Sweeny wrote:> > You can''t require Class[''test2::foo''] unless it''s already available where > you''re requiring it. You need to include test2::foo in test2::bar. > >Thanks. If I include test2:foo in test2::bar, do I still need require => [Class[''test2::foo''] on the exec? In testing this, it seems that I don''t. On Thu, May 17, 2012 at 10:53 AM, LTH wrote:> >> Hello, >> >> I''m having some trouble with subclasses accessing other subclasses within >> the same main class. >> >> I have boiled it down a general case. I have the following files: >> >> ## /etc/puppet/modules/test1 >> class test1 { >> >> class {''test2::bar'':} >> >> } >> >> ## /etc/puppet/modules/test2/init.pp >> class test2 { >> class {test2::foo} >> class {test2::bar} >> class {test2::baz} >> } >> >> ## /etc/puppet/modules/test2/foo.pp >> class test2::foo { >> # do something here in foo >> >> } >> >> ## /etc/puppet/modules/test2/bar.pp >> class test2::bar { >> # do something here that requires test2::foo >> exec { ''bar_in_tmp'': >> path => ''/usr/bin:/usr/sbin:/bin'', >> command => "touch /tmp/bar", >> creates => ''/tmp/bar'', >> require => [ >> Class[''test2::foo''], >> ], >> } >> >> } >> >> ## /etc/puppet/modules/test2/baz.pp >> >> class test2::baz { >> # do something unwanted here >> >> >> } >> >> When the agent runs it dies saying "Could not find dependence >> Class[''Test2::Foo''] for Exec[''bar_in_tmp'']" >> >> Now if I change that line in test1 to just class {''test2'':} it runs >> without error. However since the main class call test2::baz, it does more >> than I wanted. Am I not understanding something? How do I just do bar and >> foo? >> >> Thanks in advance, >> >> -LTH >> >> >> >> >> -- >> 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/-/QJOSn1NqhEsJ. >> 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. >> > > > > -- > > James Sweeny > Professional Services > http://puppetlabs.com/ > > >-- 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/-/MqrvCA3LpnYJ. 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.
James Sweeny
2012-May-17 17:14 UTC
Re: [Puppet Users] Classes, Subclasses, and Requirements
The point of the "require" parameter is to define a dependency relationship. In the example you gave, it doesn''t really make sense to have the exec require a class that does nothing (test2::foo), so you can drop the require. On the other hand, if the exec actually needed test2::foo to work correctly (for example, if test2::foo created a shell script that the exec needed to run), you would need that require or your catalog would likely fail to apply. See here for more info: http://docs.puppetlabs.com/references/stable/metaparameter.html#require On Thu, May 17, 2012 at 1:06 PM, LTH <ltharris@vcu.edu> wrote:> On Thursday, May 17, 2012 11:23:40 AM UTC-4, James Sweeny wrote: >> >> You can''t require Class[''test2::foo''] unless it''s already available where >> you''re requiring it. You need to include test2::foo in test2::bar. >> >> > Thanks. > > If I include test2:foo in test2::bar, do I still need require => > [Class[''test2::foo''] on the exec? In testing this, it seems that I don''t. > > > > > On Thu, May 17, 2012 at 10:53 AM, LTH wrote: >> >>> Hello, >>> >>> I''m having some trouble with subclasses accessing other subclasses >>> within the same main class. >>> >>> I have boiled it down a general case. I have the following files: >>> >>> ## /etc/puppet/modules/test1 >>> class test1 { >>> >>> class {''test2::bar'':} >>> >>> } >>> >>> ## /etc/puppet/modules/test2/**init.pp >>> class test2 { >>> class {test2::foo} >>> class {test2::bar} >>> class {test2::baz} >>> } >>> >>> ## /etc/puppet/modules/test2/foo.**pp >>> class test2::foo { >>> # do something here in foo >>> >>> } >>> >>> ## /etc/puppet/modules/test2/bar.**pp >>> class test2::bar { >>> # do something here that requires test2::foo >>> exec { ''bar_in_tmp'': >>> path => ''/usr/bin:/usr/sbin:/bin'', >>> command => "touch /tmp/bar", >>> creates => ''/tmp/bar'', >>> require => [ >>> Class[''test2::foo''], >>> ], >>> } >>> >>> } >>> >>> ## /etc/puppet/modules/test2/baz.**pp >>> >>> class test2::baz { >>> # do something unwanted here >>> >>> >>> } >>> >>> When the agent runs it dies saying "Could not find dependence >>> Class[''Test2::Foo''] for Exec[''bar_in_tmp'']" >>> >>> Now if I change that line in test1 to just class {''test2'':} it runs >>> without error. However since the main class call test2::baz, it does more >>> than I wanted. Am I not understanding something? How do I just do bar and >>> foo? >>> >>> Thanks in advance, >>> >>> -LTH >>> >>> >>> >>> >>> -- >>> 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/-/**QJOSn1NqhEsJ<https://groups.google.com/d/msg/puppet-users/-/QJOSn1NqhEsJ> >>> . >>> 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 <puppet-users%2Bunsubscribe@googlegroups.com>. >>> For more options, visit this group at http://groups.google.com/** >>> group/puppet-users?hl=en<http://groups.google.com/group/puppet-users?hl=en> >>> . >>> >> >> >> >> -- >> >> James Sweeny >> Professional Services >> http://puppetlabs.com/ >> >> >> -- > 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/-/MqrvCA3LpnYJ. > > 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. >-- James Sweeny Professional Services http://puppetlabs.com/ -- 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.
jcbollinger
2012-May-18 13:16 UTC
[Puppet Users] Re: Classes, Subclasses, and Requirements
On May 17, 12:14 pm, James Sweeny <james.swe...@puppetlabs.com> wrote:> The point of the "require" parameter is to define a dependency > relationship.More precisely, it defines an *application-order* relationship. What Puppet is choking on is different: a *parse-order* dependency. The former involves only order of operations on the client, whereas the latter involves only catalog compilation on the master. 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.