Knife ssh 到奇数主机
有没有办法可以 ssh 到奇数主机?
这有效:
# knife ssh "webhost1*" "chef-client"
这不起作用
# knife ssh "webhost1[13579]" "chef-client"
Is there a way I can ssh to odd numbered hosts?
this works:
# knife ssh "webhost1*" "chef-client"
this does not work
# knife ssh "webhost1[13579]" "chef-client"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要以本机方式实现此目的,您需要查看可以搜索。例如角色、标签等。一种方法是标记节点。例如,我们可以将节点标记为
odd
和even
,即webhost1[13579]
将被标记为奇数。然后可以通过以下方式定位奇数主机:
为要使用的
knife ssh
命令生成奇数更多的是 Shell 功能,例如:seq
命令将生成一个序列从1
开始,增量为2
,直到10
。请注意,这使得 SSH 执行串行,并且可能有更好或更有效的方法来生成奇数。此外,如果需要,您可以使用类似的
for
循环来标记节点。例子:To achieve this natively, you'll need to look at other properties of node that can be searched. Like roles, tags, etc. One way is to tag the nodes. For example, we can tag the nodes as
odd
andeven
, i.e.webhost1[13579]
will be tagged as odd.Then the odd hosts can be targeted by:
Generating odd numbers for the
knife ssh
command to use is more of a Shell functionality, e.g.:The
seq
command will generate a sequence starting from1
with increments of2
, till10
.Note that this makes the SSH execution serial, and there may be better or more efficient ways to generate the odd numbers. Also, you can use a similar
for
loop to tag the nodes if required. Example: