节点搜索在测试厨房中无济于事 [英] node search is giving nothing in test kitchen

查看:65
本文介绍了节点搜索在测试厨房中无济于事的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在测试厨房搜索没有输出



抛出错误,检查配方并向我建议一些细节



节点JSON文件

  {
id: cldb,
chef_type:节点,
json_class: Chef :: Node,
run_list:[],
automatic:{
hostname: cldb.net ,
fqdn: 127.0.0.1,
name: cldb.net,
ipaddress: 127.0.0.1,
roles :[],
cldb:真
}
}

Recipe






  cldbNodes = search(:node, cldb:true )

cldb =#{cldbNodes [ fqdn]}

文件'/tmp/test.txt'执行
内容#{cldb}
end


解决方案

从评论中进行总结上面的 search(...)返回一个数组,因此您需要获取特定的元素(通常是第一个元素),然后才能访问节点数据。 / p>

使用上面的示例,就像这样:

  cldbNodes = search(:node, cldb:true)

cldb = cldbNodes.first [ fqdn]

文件'/tmp/test.txt'执行
内容cldb
结束


No output from search in test kitchen

Throwing error check the recipe and suggest me some details

Node JSON file

{
    "id": "cldb",
    "chef_type": "node",
    "json_class": "Chef::Node",
    "run_list": [],
    "automatic": {
        "hostname": "cldb.net",
        "fqdn":"127.0.0.1",
        "name": "cldb.net",
        "ipaddress": "127.0.0.1",
        "roles": [],
        "cldb" : true
    }
}

Recipe


cldbNodes = search(:node, "cldb:true")

cldb = "#{cldbNodes["fqdn"]}"

file '/tmp/test.txt' do
    content "#{cldb}"
end

解决方案

To summarize from the comments above, search(...) returns an array so you need to get a specific element, usually the first, before you can access node data.

Using the example above, it would be something like:

cldbNodes = search(:node, "cldb:true")

cldb = cldbNodes.first["fqdn"]

file '/tmp/test.txt' do
    content cldb
end

这篇关于节点搜索在测试厨房中无济于事的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆