Concatenate multiple databags on a recipe chef

196 Views Asked by At

I am trying to concatenate multiple databags into a single array :

jettyrealm_prop=[]
data_bag_item('data_' + node.chef_environment, node['product']['realm_databag'].each do |item|
jettyrealm_prop.insert(item)
end)

node['product']['realm_databag'] added into attributes

but this provides this error :

[2018-09-20T10:51:49+02:00] ERROR: no implicit conversion of String into Integer

2

There are 2 best solutions below

0
On BEST ANSWER
result = node['product']['realm_databag'].map |item|
  data_bag_item('data_' + node.chef_environment, item)
end

This should work and it's more elegant!

1
On
jettyrealm_prop=[]
node['product']['realm_databag'].each do |item|
  jettyrealm_prop.push(item)
end

tab=[]
jettyrealm_prop.each do |item1|
  tab=data_bag_item('data_' + node.chef_environment, item1)
end

I splitted the ressource bloc and it works ...