On Friday, December 21, 2012 10:36:27 PM UTC-6, John Moser wrote:
>
> I'm having a case where, as with Puppet, multiple packages use the same 
> file.  For example, puppet and puppetmaster both use /etc/puppet/puppet.conf
>
> My first attempt was to have a class 'puppet::client' include a service 
> 'puppet' with a require => Class["puppet::config"], as well a class 
> 'puppet::client' include a service 'puppetmaster' with a require => 
> Class["puppet::config"]
>
> Problem:  Can't do that. Running across the same require for a class twice 
> gets an error.
>


No, that's not your problem.  Any number of classes or resources may 
'require' a given class or resource.  Similarly for the other types or 
relationships.  Also the same for relationships declared via the chain 
operators, implied by run stages, or inherited from a declaring class.

 

>
> It's not particularly important that the server or client get executed 
> first, as long as the config is executed first.  That's what the whole 
> require thing is for, right?
>
>
>

Yes, you understand the concept. You have not provided enough information 
for me to confidently identify the problem, but my first guess would be 
that it is a parse order issue.  Your manifests must not reference classes 
or resources (e.g. "Class['puppet::config']") whose declarations have not 
yet been parsed.  There are several ways to ensure a suitable parse order 
(as distinguished from the entirely separate client-side order of resource 
application).

Supposing that class 'puppet::config' is not parametrized, the easiest 
thing to do would be to use the 'require' function (not the resource 
metaparameter) to declare class 'puppet::client''s parse- and 
application-order dependency on class 'puppet::config'.  It would look like 
this:

class puppet::client {
  require 'puppet::config'

  # ... other declarations
  #
  # resources declared directly
  # by this class do not need to
  # declare any relationship to
  # class 'puppet::config' (though
  # it is harmless for them to do)
}

Alternatively, you can use 'include' instead of 'require' if you intend for 
each resource to continue to declare its own dependencies, or if you have 
other resources in class 'puppet::client' that do not need a relationship 
with class 'puppet::config'.

You may also want to consider whether you want to establish relationships 
with the config class, or whether it would be as good or better to 
establish them with particular resources declared by that class (e.g. 
File['/etc/puppet/puppet.conf']).  There are a few other variations and 
options as well, and you are more constrained if class 'puppet::config' is 
parametrized, but maybe this will get you looking in the right direction.


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/-/B4IH43KY1uMJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to