1 Puppet::Type.newtype(:anchor) do
4 A simple resource type intended to be used as an anchor in a composite class.
6 In Puppet 2.6, when a class declares another class, the resources in the
7 interior class are not contained by the exterior class. This interacts badly
8 with the pattern of composing complex modules from smaller classes, as it
9 makes it impossible for end users to specify order relationships between the
10 exterior class and other modules.
12 The anchor type lets you work around this. By sandwiching any interior
13 classes between two no-op resources that _are_ contained by the exterior
14 class, you can ensure that all resources in the module are contained.
18 # These classes will have the correct order relationship with each
19 # other. However, without anchors, they won't have any order
20 # relationship to Class['ntp'].
21 class { 'ntp::package': }
22 -> class { 'ntp::config': }
23 -> class { 'ntp::service': }
25 # These two resources "anchor" the composed classes within the ntp
27 anchor { 'ntp::begin': } -> Class['ntp::package']
28 Class['ntp::service'] -> anchor { 'ntp::end': }
32 This allows the end user of the ntp module to establish require and before
33 relationships with Class['ntp']:
36 class { 'ntp': } -> class { 'mcollective': }
37 class { 'mcollective': } -> class { 'ntp': }
43 desc 'The name of the anchor resource.'
46 # We don't do anything with them, but we need this to
47 # show that we are "refresh aware" and not break the
48 # chain of propagation.