木偶必须恨我 我一直在阅读文档几个小时,仍然无法实现以下目标:
在伪代码中,这将是:
# 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, } }