I have two modules both of which require a 3rd module. The problem of course is that if I use both modules on a node, I end up with a "Duplicate declaration" error of the third module. What''s the right way to handle two modules that both require a 3rd one? -- 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/-/jwUX9RrpZB4J. 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.
Christopher Wood
2012-Jul-30 15:34 UTC
Re: [Puppet Users] two modules require the same module
On Mon, Jul 30, 2012 at 08:28:34AM -0700, lth wrote:> I have two modules both of which require a 3rd module. The problem of > course is that if I use both modules on a node, I end up with a "Duplicate > declaration" error of the third module. > What''s the right way to handle two modules that both require a 3rd one?Use include. http://docs.puppetlabs.com/references/stable/function.html#include Modules have this: class module1::thing { include module3 } class module2::other { include module3 } Node has this: node hostname { class { ''module1::thing'': } class { ''module2::other'': } } Then the module3 class is only evaluated once. Remember dependencies if you need module3 evalated before other stuff.> -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To view this discussion on the web visit > [1]https://groups.google.com/d/msg/puppet-users/-/jwUX9RrpZB4J. > 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. > > References > > Visible links > 1. https://groups.google.com/d/msg/puppet-users/-/jwUX9RrpZB4J-- 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 Monday, July 30, 2012 11:34:22 AM UTC-4, Christopher Wood wrote:> > > Then the module3 class is only evaluated once. Remember dependencies if > you need module3 evalated before other stuff. > >Thanks for the reply. I think maybe that should have been my question. Both modules need to have module3 evaluated first which is why I was using require in both of them.> > -- > > You received this message because you are subscribed to the Google > Groups > > "Puppet Users" group. > > To view this discussion on the web visit > > [1]https://groups.google.com/d/msg/puppet-users/-/jwUX9RrpZB4J. > > 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. > > > > References > > > > Visible links > > 1. https://groups.google.com/d/msg/puppet-users/-/jwUX9RrpZB4J >-- 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/-/-LjwY_3N-tkJ. 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.
Christopher Wood
2012-Jul-30 15:53 UTC
Re: [Puppet Users] two modules require the same module
On Mon, Jul 30, 2012 at 08:48:24AM -0700, lth wrote:> On Monday, July 30, 2012 11:34:22 AM UTC-4, Christopher Wood wrote: > > Then the module3 class is only evaluated once. Remember dependencies if > you need module3 evalated before other stuff. > > Thanks for the reply. > I think maybe that should have been my question. Both modules need to > have module3 evaluated first which is why I was using require in both of > them.This may help: http://docs.puppetlabs.com/guides/language_guide.html#chaining-resources You can also require => Class[''whatever''] for something which needs said class, but that can be less optimal.> > > -- > > You received this message because you are subscribed to the Google > Groups > > "Puppet Users" group. > > To view this discussion on the web visit > > [1][1]https://groups.google.com/d/msg/puppet-users/-/jwUX9RrpZB4J. > > To post to this group, send email to > [2]puppet-users@googlegroups.com. > > To unsubscribe from this group, send email to > > [3]puppet-users+unsubscribe@googlegroups.com. > > For more options, visit this group at > > [4]http://groups.google.com/group/puppet-users?hl=en. > > > > References > > > > Visible links > > 1. [5]https://groups.google.com/d/msg/puppet-users/-/jwUX9RrpZB4J > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To view this discussion on the web visit > [6]https://groups.google.com/d/msg/puppet-users/-/-LjwY_3N-tkJ. > 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. > > References > > Visible links > 1. https://groups.google.com/d/msg/puppet-users/-/jwUX9RrpZB4J > 2. mailto:puppet-users@googlegroups.com > 3. mailto:puppet-users%2Bunsubscribe@googlegroups.com > 4. http://groups.google.com/group/puppet-users?hl=en > 5. https://groups.google.com/d/msg/puppet-users/-/jwUX9RrpZB4J > 6. https://groups.google.com/d/msg/puppet-users/-/-LjwY_3N-tkJ-- 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 Monday, July 30, 2012 11:53:55 AM UTC-4, Christopher Wood wrote:> > On Mon, Jul 30, 2012 at 08:48:24AM -0700, lth wrote: > > On Monday, July 30, 2012 11:34:22 AM UTC-4, Christopher Wood wrote: > > > > Then the module3 class is only evaluated once. Remember > dependencies if > > you need module3 evalated before other stuff. > > > > Thanks for the reply. > > I think maybe that should have been my question. Both modules need > to > > have module3 evaluated first which is why I was using require in > both of > > them. > > This may help: > > http://docs.puppetlabs.com/guides/language_guide.html#chaining-resources > > You can also require => Class[''whatever''] for something which needs said > class, but that can be less optimal. > >Ah yes that looks like it will work. Thanks!> > > > > -- > > > You received this message because you are subscribed to the > Google > > Groups > > > "Puppet Users" group. > > > To view this discussion on the web visit > > > [1][1] > https://groups.google.com/d/msg/puppet-users/-/jwUX9RrpZB4J. > > > To post to this group, send email to > > [2]puppet-users@googlegroups.com. > > > To unsubscribe from this group, send email to > > > [3]puppet-users+unsubscribe@googlegroups.com. > > > For more options, visit this group at > > > [4]http://groups.google.com/group/puppet-users?hl=en. > > > > > > References > > > > > > Visible links > > > 1. [5] > https://groups.google.com/d/msg/puppet-users/-/jwUX9RrpZB4J > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "Puppet Users" group. > > To view this discussion on the web visit > > [6]https://groups.google.com/d/msg/puppet-users/-/-LjwY_3N-tkJ. > > 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. > > > > References > > > > Visible links > > 1. https://groups.google.com/d/msg/puppet-users/-/jwUX9RrpZB4J > > 2. mailto:puppet-users@googlegroups.com > > 3. mailto:puppet-users%2Bunsubscribe@googlegroups.com > > 4. http://groups.google.com/group/puppet-users?hl=en > > 5. https://groups.google.com/d/msg/puppet-users/-/jwUX9RrpZB4J > > 6. https://groups.google.com/d/msg/puppet-users/-/-LjwY_3N-tkJ >-- 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/-/ICkyPXcFisAJ. 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 Monday, July 30, 2012 11:35:38 AM UTC-5, lth wrote:> > On Monday, July 30, 2012 11:53:55 AM UTC-4, Christopher Wood wrote: >> >> On Mon, Jul 30, 2012 at 08:48:24AM -0700, lth wrote: >> > On Monday, July 30, 2012 11:34:22 AM UTC-4, Christopher Wood wrote: >> > >> > Then the module3 class is only evaluated once. Remember >> dependencies if >> > you need module3 evalated before other stuff. >> > >> > Thanks for the reply. >> > I think maybe that should have been my question. Both modules need >> to >> > have module3 evaluated first which is why I was using require in >> both of >> > them. >> >> This may help: >> >> http://docs.puppetlabs.com/guides/language_guide.html#chaining-resources >> >> You can also require => Class[''whatever''] for something which needs said >> class, but that can be less optimal. >> >> > Ah yes that looks like it will work. Thanks! >No, it won''t. At least not robustly. Using the ''require'' metaparameter expresses a client-side order-of-application constraint between the resource on which the parameter is set and the one(s) specified as its value. That creates a (server-side) parse-order dependency: Class[''whatever''] needs to have already been parsed when the ''require'' parameter is parsed. There is nothing inherently wrong with that, but you do need to ensure a viable parse order. If Class[''whatever''] is not parameterized, then the best way to ensure that it is parsed first is via the ''include'' or ''require'' *function*. If using the ''require'' function was giving you a duplicate definition error before, then so also should the ''include'' function do now. Frankly, though, I''m not sure why or how that would happen. It is completely valid for different classes to ''include'' the same class, and it means the same thing (to the client) as if the class were included only once. Likewise for the ''require'' function, except that it also creates a relationship between the class or resource in which it appears and the target class. It also can be used multiple times on the same class. I''m going to need to see some actual code if I''m to provide any specific analysis or advice. Preferably, that would be in the form of a minimal example that exhibits the problem. Alternatively, you may find that the process of preparing such a minimal example helps you identify the real problem for yourself. 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/-/k8ArDZgtDeIJ. 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.