简体   繁体   English

按Chef区域中的AWS区域搜索节点

[英]Search nodes by AWS regions in Chef recipes

我目前做的事情就像nodes = search(:node, "chef_environment:#{node.chef_environment} AND recipes:recipe_name)以获得具有相同厨师环境和食谱名称的所有节点。但是,我有几个单区域集群,使用相同的厨师环境和食谱名称,我想知道是否有一种方法可以添加到搜索查询,如region键,只能获取位于同一AWS区域的节点。

Unfortunately and bizarrely the answer is no. 不幸的是,奇怪的是答案是否定的。 The semi official solution from Amazon is to take the AZ name and trim off the last letter but that doesn't help with search. 亚马逊的半官方解决方案是采用AZ名称并删除最后一个字母,但这对搜索没有帮助。 You could make your own custom Ohai plugin to do that though. 你可以制作自己的自定义Ohai插件来做到这一点。 No one seems to be sure why Amazon doesn't offer the plain region name via the metadata service. 似乎没有人确定亚马逊为什么不通过元数据服务提供普通的区域名称。

EDIT: A more specific example 编辑:一个更具体的例子

search(:node, "ec2_placement_availability_zone:#{node['ec2']['placement']['availability_zone'][0..-2]}*")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM