On Tuesday, November 19, 2013 9:23:21 AM UTC-6, Jon McKenzie wrote: > > Thanks for the replies and being patient with me! > > Maybe I'm thinking about this incorrectly, but it seems to me that > announcing a dependency ("I need x defined somewhere in order to work > properly") shouldn't require a class to declare the dependency as well. It > seems to me that the dependent class should not have to know anything about > how a particular dependency is defined, just that it is defined. >
The 'include' function, and its cousins 'require' and 'contain', serve the purpose of requiring that a certain class be declared without needing to know the details of its declaration. However, they are bona fide declarations, not mere assertions, so if the named class(es) has not yet otherwise been declared then they serve also to declare it with default parameters. An other way to look at it is that the 'include' statement should not be read as applying to the class or definition in which it appears, but rather to the target node's catalog. The statement "include 'foo'" means "ensure that class foo is in the target node's catalog". The 'require' and 'contain' functions should be understood by analogy with 'include', though they add ordering requirements that do relate to the class in which they appear. This is in part historical. Prior to Puppet 2.6, 'include' and 'require' were the only means available to declare classes. The parameterized-style declarations added in v2.6 were not a good fit, and they still aren't today. Today, however, you can use parameterized classes without the parameterized-style declaration syntax. > > As an analogy to RPM package dependencies, if I have a package called > Django that requires a package which provides the "python" capability, the > Django package shouldn't need to include it's own version of Python. It > should be able to re-use any package which has the capability. > > The 'include' function is more analogous to an RPM requirement than not. In particular, note that 1) 'include' is NOT analogous to the C preprocessor's #include directive -- it does not perform interpolation, and 2) Puppet classes are idempotent. Declaring the same class (successfully) multiple times has no different effect than declaring it exactly once. > > What does one have to do with the other? >> > > You were suggesting using auto-lookups via Hiera to populate class > parameters, but we're using Foreman to populate those parameters. AFAIK, > there's no interoperability between Foreman's ENC and Hiera (without > writing my own). > > > Foreman will not populate an Hiera data file, as far as I am aware, but that does not mean you cannot use both. Puppet performs an hiera lookup for every parameter that is not explicitly assigned a value, ENC or no ENC. Surely Foreman does not force you to assign a value for every parameter of every class? In any case, an ENC is not relevant to the sample code about which you inquired. That code issues explicit declarations of the class in question. If instead you are having difficulties related to classes declared via an ENC colliding with 'include'd or 'require'd classes then let's direct the discussion that way, but I am not certain whether such an issue occurs. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/3020d3cd-3253-49f7-8f41-fa49ab63e4d5%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.