I just started playing with chef today, and one thing I can't wrap my head around is how I can use data bags to store multiple key-values in one item (1 bag > 1 item > many key-values) and be able to invoke them one by one within a recipe.
Here is a simple test to delete directory if the directory from databag exists.
directory 'bag_item[installvar.testbag]['testdir'])' do
action :delete
only_if { Dir.exist?(bag_item[installvar.testbag]['testdir']) }
end
Obviously I'm not using the index right but I'm not strong in ruby at all, I didn't know what ruby was until couple of weeks ago... all the googling points me at examples of mass usage on multiple items by one key-value, which is not what I am trying to achieve. databag is installvar itemID is testbag and the key I'm looking to retrieve is testdir.