gpt4 book ai didi

puppet - 为什么模块在 puppet 中使用类(而不是定义)

转载 作者:行者123 更新时间:2023-12-04 17:49:42 24 4
gpt4 key购买 nike

我一直在为 puppet 创建几个类(在不同的模块中)。两者分别需要 Maven。所以这两个类都有以下内容:

    class { "maven::maven":
version => "3.0.5"
}

(使用 puppet forge 的 https://forge.puppetlabs.com/maestrodev/maven 模块)

但是,如果我有一个节点同时包含我的两个类,puppet 会提示,因为类 'maven::maven' 被声明了两次。我觉得我的每个类(class)都应该可以自由地声明它需要的所有东西。如果一个节点有多个类,这两个类都需要 Maven,那么我看不到问题所在。

所以,我的问题是:该 maven 模块的作者是否错误地使用了一个类,他应该使用定义来代替吗? (因为您可以多次使用/调用/任何定义)。看来,如果他使用了一个定义,我就可以随意多次使用该代码块,所以如果他使用类是正确的,为什么?

谢谢。

最佳答案

我认为这背后的基本原理在 John Arundel's Puppet 3 Beginner's Guide 中得到了最好的解释。 :

So if you're wondering which to use, consider:

  • Will you need to have multiple instances of this on the same node (for example, a website)? If so, use a definition.
  • Could this cause conflicts with other instances of the same thing on this node (for example, a web server)? If so, use a class.

关于puppet - 为什么模块在 puppet 中使用类(而不是定义),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20052763/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com