The role of anchor in puppet

Source: Internet
Author: User

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 '],

}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.