1 Puppet::Type.newtype(:anchor) do
3 A simple resource type intended to be used as an anchor in a composite class.
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.
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.
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': }
23 # These two resources "anchor" the composed classes within the ntp
25 anchor { 'ntp::begin': } -> Class['ntp::package']
26 Class['ntp::service'] -> anchor { 'ntp::end': }
29 This allows the end user of the ntp module to establish require and before
30 relationships with Class['ntp']:
32 class { 'ntp': } -> class { 'mcollective': }
33 class { 'mcollective': } -> class { 'ntp': }
38 desc "The name of the anchor resource."
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.