大网数据广告活动
服务器运维问答

Grouping nodes in puppet

· 52CE 我爱测

In my site.pp manifest, I have the following import "nodes/*.pp" This lets me nicely create separate files for different groups. However, inside each .pp file, i still have to explicitly set the name of the nodes I want to apply …

问题原文

原帖链接 · Toby · CC BY-SA 3.0

In my site.pp manifest, I have the following

import "nodes/*.pp"

This lets me nicely create separate files for different groups. However, inside each .pp file, i still have to explicitly set the name of the nodes I want to apply modules and classes to, as so:

node puppet-client-1 {
  include testmodule
}

My question is, How do I group a number of nodes together, and then apply modules and/or classes to that node group? eg:

group testgroup{
  puppet-client1
  puppet-client2
}

node webservers
{
  include testmodule
}

While I am here, my log is spitting out this:

The use of 'import' is deprecated at /etc/puppet/manifests/site.pp:2

If this is deprecated, how do I split out my manifest files into groups?

Thanks :)

已采纳解答

原帖链接 · Craig Miskell · CC BY-SA 4.0

There's two ways:

1) Multiple node names in one line:

node 'puppet-client1', 'puppet-client2' {
    include testmodule
}

2) Nodes can be defined with regexes, e.g.:

node /^puppet-client[0-9]+/{
  include testmodule
}

but that depends on a suitable host naming scheme.

You can see the official documentation for node definitions.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-04-25)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。