-
Notifications
You must be signed in to change notification settings - Fork 583
stdlib should provide an anchor resource for composite classes #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
With Puppet 2.6.x we do not have a way to specify containment relationships. In the use case of class ntp { } declaring ntp::{package,config,service} classes, the ntp class itself should allow the user to specify before and require relationships to the main ntp class. The anchor resource type allows module authors to close the loop on classes composing the main top level module. For example: class ntp { class { 'ntp::package': } -> class { 'ntp::config': } -> class { 'ntp::service': } # These two resources "anchor" the composed classes # such that the end user may use "require" and "before" # relationships with Class['ntp'] anchor { 'ntp::begin': } -> class { 'ntp::package': } class { 'ntp::service': } -> anchor { 'ntp::end': } } Using this pattern, the module user may then simply declare relationships to the ntp class as they expect: class { 'ntp': } -> class { 'mcollective': } # OR class { 'mcollective': } -> class { 'ntp': }
Unlike the whit type the anchor type derives from, we are not hacking the stringify method. We expect the resource to be named simply Anchor[foo::bar] where the name is "foo::bar".
I am sure I am missing something but I don't understand why this is needed? If I have a class that includes subclasses .. why wont require and before work with them without this extra anchor magic? I have been following the pro-puppet book and have the layout you describe there. and I have classes require Class['ntp'] and I think its working for me .. btw I see the anchor used the mcollective modules and I am still trying to grok it all. I would like to expand the module to be able to choose rabbitmq as the backend. |
Closes pull request #12 Reviewed-by: Jeff McCune Verified all spec tests pass using rspec **/*_spec.rb * issue/master/8797_puppetlabs-functions_merge: (164 commits) * Moved kwalify to puppetlabs-kwalify project * Re-arranged tests in line with puppetlabs-stdlib Prep for stdlib merge * Renamed load_yaml & load_json to parseyaml & parsejson * Renamed is_valid_* functions and remove the 'valid_' Fix some ruby 1.9.2 issues. (#3) Provide documentation for remaining functions. (#3) Apply missing documentation to more functions. Remove rand. Some improvements to values_at tests. (#1) provide some more detailed tests for a number of functions. Removed date stub since this functinality is available in strftime anyway. (#2) fix is_string finally so it also makes sure numbers return false. (#2) unstub is_valid_domain_name Added doc strings for first five functions Removed join_with_prefix. (#2) unstub is_valid_mac_address. Allow sort for strings. Count functionality overlaps with size - so removing it. Removed crontab functions instead of unstubbing them. Removed load_variables. load_yaml is sufficient to solve this problem on its own. Remove is_valid_netmask instead of unstubbing. Doesn't seem like a sensible function on its own. (#2) unstub is_numeric function. ...
@eedgar I've emailed you with more information about the anchor type included in the stdlib module. Do you think this should be better documented in the stdlib module itself? Currently most of our documentation related to the anchor resources are internal documents that aren't widely distributed to the community. If so, could you please file a feature request to document the anchor type in the stdlib module? The place to do so is at: Thanks, |
This is largely based on a discussion on the internal tech mailing list.
There is a need to make modules easy for end users to establish relationships to.
For example:
OR
If the ntp or mcollective classes are compositions of other classes, such as {ntp,mcollective}::{package,config,service}, then the composed classes must be somehow contained within the ntp or mcollective class.
We can work around this in 2.6.x today using resources as anchors:
A resource similar to a Whit should be added to the standard library to provide these anchor points. The resource should do nothing and always be in sync.
The text was updated successfully, but these errors were encountered: