Manage data bag dependencies?


#1

Hi,

some cookbooks require data bags and especially wrapper- and role cookbooks tend to require a chain of (encrypted) data bags.
AFAIK there is no way to describe the dependency/relationship of a cookbooks to data bags, e.g., through some metadata.rb attribute.

This is a problem if you use chef-solo/knife-solo or a lot of different chef-servers/organizations: You almost always forget to upload/create data bags and need to debug it by hand.

Any suggestions?

Best regards
Roland


#2

On Nov 28, 2014, at 6:41 AM, Roland Moriz rmoriz@gmail.com wrote:

Hi,

some cookbooks require data bags and especially wrapper- and role cookbooks tend to require a chain of (encrypted) data bags.
AFAIK there is no way to describe the dependency/relationship of a cookbooks to data bags, e.g., through some metadata.rb attribute.

This is a problem if you use chef-solo/knife-solo or a lot of different chef-servers/organizations: You almost always forget to upload/create data bags and need to debug it by hand.

Any suggestions?

Stop using data bags and use cookbooks instead. You can use recipes and resources to the same effect.

–Noah


#3

Am 28.11.2014 um 18:22 schrieb Noah Kantrowitz noah@coderanger.net:
On Nov 28, 2014, at 6:41 AM, Roland Moriz rmoriz@gmail.com wrote:

some cookbooks require data bags and especially wrapper- and role cookbooks tend to require a chain of (encrypted) data bags.
AFAIK there is no way to describe the dependency/relationship of a cookbooks to data bags, e.g., through some metadata.rb attribute.

This is a problem if you use chef-solo/knife-solo or a lot of different chef-servers/organizations: You almost always forget to upload/create data bags and need to debug it by hand.

Any suggestions?

Stop using data bags and use cookbooks instead. You can use recipes and resources to the same effect.

That’s not always an option because we need to encrypt credentials and therefore need to use encrypted data bags.
I usually have a recipe inside a cookbook that just tries to open an encrypted data bag and copy the data to the node object (force_default-level) - so we have both options.
https://gist.github.com/rmoriz/c95118441dd93cfda3c3 https://gist.github.com/rmoriz/c95118441dd93cfda3c3

But let’s take an easier and open source example:
https://github.com/opscode-cookbooks/supermarket https://github.com/opscode-cookbooks/supermarket

This cookbook requires a data bag but you need to know
https://github.com/opscode-cookbooks/supermarket/blob/master/recipes/_application.rb#L44 https://github.com/opscode-cookbooks/supermarket/blob/master/recipes/_application.rb#L44
and
https://github.com/opscode-cookbooks/supermarket/blob/master/attributes/default.rb#L33 https://github.com/opscode-cookbooks/supermarket/blob/master/attributes/default.rb#L33

to be aware of the dependency. Not a way to „automagically“ get the data bag requirement.

best regards
Roland