我可以写
include '::ntp'
Run Code Online (Sandbox Code Playgroud)
或者我可以写
class { '::ntp':}
Run Code Online (Sandbox Code Playgroud)
它们之间有什么区别,还是我都需要?
小智 10
有区别,这里有两个大的区别:
Usinginclude
允许一个类的多个声明。该class
声明只能使用一次,否则您将看到重复的资源声明错误。
include
将使用外部数据,例如 hiera,作为参数。声明class
允许您指定参数。
见https://puppet.com/docs/puppet/latest/lang_classes.html#the-include-function