Chef data bag creation from a recipe

Viewed 4303

How to create a data bag from a recipe and avoid the exception when that data bag already exists?

The documentation shows that creating a data bag is done like this:

new_databag = Chef::DataBag.new
new_databag.name('unique_name')
new_databag.save

This works when the databag does not exist yet, but how to make it work if the databag already exists so it will not break the chef run?

1 Answers
Related