node 'node-slave01' {
include repo::git
include fun::cmatrix
}
node 'node-slave02' {
include repo::hg
include fun::toilet
}
node 'node-slave03' {
include fun::rup
include repo::svn
include fun::cmatrix
}
node 'node-slave04' {
include repo::git
include repo::hg
include repo::svn
include fun::cmatrix
include fun::toilet
}
node /node-slave\d+/ {
include lamp
include test
include fun::rup
include sup
}
因此,所有内容都/node-slave\d+/
不会运行。如果我将sup
模块放在 4 个节点中的任何一个节点下,它会在我编写后运行sudo puppet agent --test
,但如果它在正则表达式下则不会。
如果我想让某些节点做某些事情,但有一些命令我希望它们全部执行,我该怎么做?在每个节点下写include sup
似乎非常烦人。
Puppet 匹配一个节点,一旦匹配就停止。FQDN 是最高的,它可以使用默认值。请参阅匹配部分 - https://puppet.com/docs/puppet/4.10/lang_node_definitions.html。
一种方法是只使用正则表达式节点,然后使用 case 语句来处理每个节点独有的内容
node /node-slave\d+/ { include lamp include test include fun::rup include sup
case $::hostname { 'node-slave01': { include repo::git include fun::cmatrix } node-slave02': { include repo::hg include fun::toilet } } }