Douglas Garstang
2011-Aug-23 17:51 UTC
[Puppet Users] Difference between include and require
Can someone please succinctly explain to me the difference between include and require? The documentation implies that simply putting ''require <class>'' at the top of a different class automatically means that <class> is fully implemented as a dependency. However, it doesn''t seem to work that way. Also, I''m not seeing a situation where the use of include seems to be automatically resolving dependancies. This is puppet 0.25.5. Doug -- 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.
David Kavanagh
2011-Aug-23 17:53 UTC
Re: [Puppet Users] Difference between include and require
It seems there''s a problem including a class multiple times. By stating that one class requires another, you formalize the dependency, but don''t actually have an include. What you do then is to include the class in your main implementation which uses that class. That way, if you have several classes that depend on one other class, it is included once at the top level, but used many places (where it is required). Is that as clear as I think it is? David On Tue, Aug 23, 2011 at 1:51 PM, Douglas Garstang <doug.garstang@gmail.com> wrote:> Can someone please succinctly explain to me the difference between include > and require? > The documentation implies that simply putting ''require <class>'' at the top > of a different class automatically means that <class> is fully implemented > as a dependency. However, it doesn''t seem to work that way. Also, I''m not > seeing a situation where the use of include seems to be automatically > resolving dependancies. This is puppet 0.25.5. > Doug > > -- > 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.
Douglas Garstang
2011-Aug-23 22:10 UTC
Re: [Puppet Users] Difference between include and require
Yes... that''s what I had.... On Tue, Aug 23, 2011 at 10:53 AM, David Kavanagh <dkavanagh@gmail.com>wrote:> It seems there''s a problem including a class multiple times. By > stating that one class requires another, you formalize the dependency, > but don''t actually have an include. What you do then is to include the > class in your main implementation which uses that class. That way, if > you have several classes that depend on one other class, it is > included once at the top level, but used many places (where it is > required). > Is that as clear as I think it is? > > David > > On Tue, Aug 23, 2011 at 1:51 PM, Douglas Garstang > <doug.garstang@gmail.com> wrote: > > Can someone please succinctly explain to me the difference between > include > > and require? > > The documentation implies that simply putting ''require <class>'' at the > top > > of a different class automatically means that <class> is fully > implemented > > as a dependency. However, it doesn''t seem to work that way. Also, I''m not > > seeing a situation where the use of include seems to be automatically > > resolving dependancies. This is puppet 0.25.5. > > Doug > > > > -- > > 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. > >-- Regards, Douglas Garstang http://www.linkedin.com/in/garstang Email: doug.garstang@gmail.com Cell: +1-805-340-5627 -- 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
2011-Aug-24 13:21 UTC
[Puppet Users] Re: Difference between include and require
On Aug 23, 12:51 pm, Douglas Garstang <doug.garst...@gmail.com> wrote:> Can someone please succinctly explain to me the difference between include > and require?The ''require'' function (not to be confused with the ''require'' resource metaparameter) does everything that ''include'' does, plus adds a class- level dependency. Thus, this: class foo { require ''bar'' } is equivalent to this: class foo { include ''bar'' } Class[''bar''] -> Class[''foo''] To put it another way, ''include'' affects only catalog compilation, whereas ''require'' affects both compilation by the master and application by the agent.> The documentation implies that simply putting ''require <class>'' at the top > of a different class automatically means that <class> is fully implemented > as a dependency.I''m not sure what you mean by that> However, it doesn''t seem to work that way. Also, I''m not > seeing a situation where the use of include seems to be automatically > resolving dependancies. This is puppet 0.25.5.I can''t really offer any advice based on that description of the problem. Can you provide an example that demonstrates it? 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.
jcbollinger
2011-Aug-24 13:32 UTC
[Puppet Users] Re: Difference between include and require
On Aug 23, 12:53 pm, David Kavanagh <dkavan...@gmail.com> wrote:> It seems there''s a problem including a class multiple times. By > stating that one class requires another, you formalize the dependency, > but don''t actually have an include. What you do then is to include the > class in your main implementation which uses that class. That way, if > you have several classes that depend on one other class, it is > included once at the top level, but used many places (where it is > required). > Is that as clear as I think it is?Not to me. To the extent that I understand what you''re saying, it doesn''t sound right. The ''require'' function does everything that ''include'' does (and then some), so using ''require'' vs. ''include'' does nothing to address any problems with multiple inclusion. Furthermore, the issues with multiple inclusion are sufficiently mild that my preferred coding practice is to rely on including classes everywhere they are needed. To my knowledge, multiple inclusion is problematic only in these cases: 1) When the included class uses a variable resolved via dynamic scoping, and that variable may be resolved differently at different points of inclusion. That doesn''t bother me much, because if ever that happens then it reflects a design error in the manifests anyway. There are alternative, better ways to feed data to your classes than dynamically scoped variables. 2) When the class to ''include'' is parameterized (but I consider this more a flaw in the design of the parameterized class framework than in the ''include'' function). 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.