相同的类/模块/ orwhateveritis多次

木偶必须恨我 我一直在阅读文档几个小时,仍然无法实现以下目标:

  • 一个类或模块(或称为什么)与一个variables(参数化类?);
  • 这个类将被包含多次在一个单一的主机。

在伪代码中,这将是:

# The class classorwhatever myclass ($value) { notify { "$value world" } } # In the node definition node whatever { myclass("Hello") myclass("Goodbye") } 

我觉得这很愚蠢,甚至不好笑。 我知道这一定是可行的。 但是,如何? 🙁

您只能使用一次参数化的类。 如果您计划在使用函数的同时多次敲击节点,则需要改变数据定义。

 class apache ( $module ) { if module = ssl then and so on } define apache::vhost ($priority=99) { file { "apache/vhost.d/${name}": content => template("apache/vhosts/$name.erb"), } } node webserver { class { 'apache': module => 'ssl', } apache::vhost { 'www': priority => 00, } apache::vhost { 'test': priority => 99, } }