source: other-projects/hathitrust/vagrant-solr-cluster/trunk/modules/stdlib/lib/puppet/type/anchor.rb@ 30960

Last change on this file since 30960 was 30960, checked in by davidb, 7 years ago

Switch to using Puppet to provision machine. Strongly based on files developed for spark-hdfs cluster

File size: 1.7 KB
Line 
1Puppet::Type.newtype(:anchor) do
2 desc <<-'ENDOFDESC'
3 A simple resource type intended to be used as an anchor in a composite class.
4
5 In Puppet 2.6, when a class declares another class, the resources in the
6 interior class are not contained by the exterior class. This interacts badly
7 with the pattern of composing complex modules from smaller classes, as it
8 makes it impossible for end users to specify order relationships between the
9 exterior class and other modules.
10
11 The anchor type lets you work around this. By sandwiching any interior
12 classes between two no-op resources that _are_ contained by the exterior
13 class, you can ensure that all resources in the module are contained.
14
15 class ntp {
16 # These classes will have the correct order relationship with each
17 # other. However, without anchors, they won't have any order
18 # relationship to Class['ntp'].
19 class { 'ntp::package': }
20 -> class { 'ntp::config': }
21 -> class { 'ntp::service': }
22
23 # These two resources "anchor" the composed classes within the ntp
24 # class.
25 anchor { 'ntp::begin': } -> Class['ntp::package']
26 Class['ntp::service'] -> anchor { 'ntp::end': }
27 }
28
29 This allows the end user of the ntp module to establish require and before
30 relationships with Class['ntp']:
31
32 class { 'ntp': } -> class { 'mcollective': }
33 class { 'mcollective': } -> class { 'ntp': }
34
35 ENDOFDESC
36
37 newparam :name do
38 desc "The name of the anchor resource."
39 end
40
41 def refresh
42 # We don't do anything with them, but we need this to
43 # show that we are "refresh aware" and not break the
44 # chain of propagation.
45 end
46end
Note: See TracBrowser for help on using the repository browser.