【发布时间】:2017-06-05 09:08:55
【问题描述】:
我正在管理一些只能在一台服务器上运行的脚本。我已经决定找出分配给给定角色的主机的最佳方法是进行搜索,然后选择返回的数组中的第一个元素。
像这样:
q = "roles:thumper"
arr = search(:node, q, filter_result: { fqdn: ['fqdn'] }).map { |n| n['fqdn'] }
# => ["1.example", "2.example"]
arr.first
# "1.example"
这在现实和 chef-shell 中运行良好,但在测试厨房中遇到困难,我在搜索命令中返回 HTTP 500。
================================================================================
Recipe Compile Error in /tmp/kitchen/cache/cookbooks/test/recipes/full.rb
================================================================================
Net::HTTPFatalError
-------------------
500 "Internal Server Error"
我将 chef_zero 与 vagrant 驱动程序一起使用。要让搜索功能在这种情况下正常工作,有什么特别需要做的吗?
集成json:
{
"id": "thumper",
"environment": "food",
"run_list": ["role["thumper]"],
"automatic": {
"fqdn": "thumper",
"ipaddress": "10.10.10.10",
"roles": ["thumper"],
"environment": "food"
}
}
夹具数据只是调用相关的说明书
include_recipe 'test_helpers'
include_recipe 'role_thumper'
【问题讨论】: