有没有办法在puppetmaster的nodes.pp中定义通配符主机
说我想在一个域中的所有主机接收一组类可以做我喜欢的东西:
# nodes.pp # node basenode { include admina, adminb, admic } node "*.acme.com" { include adminc }
不是这样。 您可以创build一个适用于任何签名客户端的“默认”节点。
node "default" { include foo }
但是你只能有1个默认值。 如果要复制所描述的function,可以使用external_nodes分类方法。 基本上你写一个脚本,当客户端连接时返回有效的yaml。 该脚本可以做任何你想要的,检查fqdn,查询数据库,命中ldap等
正则expression式现在可能在Puppet 0.25中,所以你想要的可能是:
node /^(foo|bar)\.example\.com$/ { include blah }
很less有发行版发行0.25,所以在我的Centos5中,EPEL repo的版本是2.24.8,我不得不为wn10.example.com这样的主机名为我的工作节点做这样的事情:
node default { $node_type = regsubst($hostname, '^([az]+).*$', '\1') case $node_type{ wn: {include worker_node} default: {include generic_node} } }