Anchor Background: puppet Forge is an online module repository. Many puppet modules are uploaded for download. You can download a module and use it directly. You should not change the manifests in it.
However, in puppet2.6, when a class declares another class, the declared class resources will not be included by the external class, this makes it impossible for us to form a module with complex functions through some simple small class files. To solve this problem, anchor is introduced.
See: http://projects.puppetlabs.com/projects/puppet/wiki/Anchor_Pattern for specific examples
It can be seen that anchor exists to include the introduced class resources.
Before using anchor, make sure that the puppetlabs/stdlib module is installed. Note the following when using anchor:
L The contained class must be between two uniquely named anchor
L any included class must determine its relationship with anchor, for example:
Anchor {'ntp _ first ':}->Class['Ntp: Service'] ->Anchor {'ntp _ la ':}
In Versions later than puppet3.4.0, The contain method is used to replace anchor.
Class NTP {
File {'/etc/NTP. conf ':
...
Require => package ['ntp '],
Policy => class ['ntp: service'],
}
Contain NTP: Service
Package {'ntp ':
...
}
}
Include NTP
Exec {'/usr/local/bin/update_custom_timestamps.sh ':
Require => class ['ntp '],
}