Chef infra 厨师长-资料袋查询

Chef infra 厨师长-资料袋查询,chef-infra,databags,Chef Infra,Databags,在查询数据包以设置节点属性时,是否可以执行以下操作 我有一系列与本地节点['fqdn']属性匹配的数据包项 是否可以动态地将此属性插入数据包查询字符串中,下面的示例不起作用,还有其他想法吗 default['test']['attribute'] = Chef::DataBagItem.load('databagname', '<%= node[:platform_version] %>')['test']['bag']['location'] default['test']['a

在查询数据包以设置节点属性时,是否可以执行以下操作

我有一系列与本地节点['fqdn']属性匹配的数据包项

是否可以动态地将此属性插入数据包查询字符串中,下面的示例不起作用,还有其他想法吗

default['test']['attribute'] = Chef::DataBagItem.load('databagname', '<%= node[:platform_version] %>')['test']['bag']['location']
default['test']['attribute']=Chef::DataBagItem.load('databagname','')['test']['bag']['location']

方法返回一个databag对象。因此,我通常将返回的数据包对象存储到一个临时变量中,然后从数据包中获取所需的项,就像使用散列一样。例如:

temp = Chef::DataBagItem.load('databagname', node.platform_version)
node.default['test']['attribute'] = temp['id'] 
您可以将id替换为所需的数据包元素

另一方面,如果您的意思是将孔数据包存储在单个属性中,我还没有尝试过,也不知道这是否可行