Puppet:如何仅在特定 nodes/ip 上安装软件包 httpd?

Puppet: how to install package httpd only on specific nodes/ip?

假设有10台服务器,但我只想在两台服务器上安装httpd并且OS必须是Centos,我用这个清单试过

class apache {
        if $::operatingsystem == 'CentOS' {
                package { "httpd":
                        ensure => latest
                }
        }
}
node '10.2.0.5' {
        include apache
}

node '10.2.0.6' {
        include apache
}

但是应用目录失败。 我尝试用 httpd 替换 apache.. 但没有成功。

找到解决方案,我不得不为特定主机声明一个名为 testmodule(名称可以是随机的)的 class 和 select 包,对于其他主机,我现在什么都不放,但我可以 select 其他动作。 经过测试,完美运行。

class testmodule {
package { ['telnet', 'glusterfs', 'wget']:
ensure => installed,
}
}

node 'node1.mysite.example', 'node2.mysite.example' {
  include testmodule
}

node 'default' {
}