rubychef-infradatabags

Concatenate multiple databags on a recipe chef


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


Solution

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

    This should work and it's more elegant!