0
votes

I have a need to add several packages from a data bag of a specific version. so far I have a data bag that works with the package resource:

{
  "id": "server_apps",
  "apps": [
   "vim",
   "tmux",
   "ntop"
 ]
}

And the recipe code:

server_apps = data_bag_item('linapps','server_apps')
package server_apps['apps']

But I'm not sure what the json structure would look like to install specific versions of the packages in a data bag - for instance a single package works like this:

package 'vim' do          
  version '7.4.160-1.el7'
end

Not sure how to specify that in a repeatable json hash however... Any ideas on how to make this work?

1

1 Answers

2
votes

There is no specific structure, what you probably want is something like this:

package server_apps['apps'].keys do
  version server_apps['apps'].values
end

and change it from an array to a hash, e.g. like the following:

{
  "id": "server_apps",
  "apps": {
   "vim": "7.4.160-1.el7",
   "tmux": "1.2.3",
   "ntop": "0.0.1"
  }
}