--在nodes.pp中定义通配符主机


10

有没有一种方法可以在puppetmaster的nodes.pp中定义通配符主机

说我希望一个域中的所有主机都接收一组类,我可以这样做吗:

# nodes.pp
#

node basenode {
  include  admina, adminb, admic
  }


node "*.acme.com" {
    include adminc
    }

Answers:


9

不是这样。您可以创建一个“默认”节点,该节点将应用于任何已签名的客户端。

node "default" {
   include foo
}

但是您只能有1个默认值。如果要复制所描述的功能,则可以使用external_nodes分类方法。基本上,您编写的脚本会在客户端连接时返回有效的Yaml。该脚本可以按照您想要的方式进行操作,检查fqdn,查询数据库,命中ldap等。


+1同意external_nodes
David Pashley 2009年

16

现在在Puppet 0.25中可以使用正则表达式,因此您可以执行以下操作:

node /^(foo|bar)\.example\.com$/ {
include blah
}

3

到目前为止,很少有发行版0.25发行,所以在我的具有来自EPEL回购的2.24.8的Centos5中,我必须对具有主机名wn10.example.com的工作程序节点执行以下操作:

node  default {
    $node_type = regsubst($hostname, '^([a-z]+).*$', '\1')
    case $node_type{
        wn: {include worker_node}
        default: {include generic_node}
    }
}

快速更新-EPEL现在提供puppet-2.6.12-1.el5.noarch(支持节点名称中的正则表达式)。
质粒87
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.