Reputation: 21226
I have several different servers used for different purposes. Everyone use mysql, but it should be configured a little bit different. => Different users, different databases.
I have a cookbook that installes mysql.
The question is, where should I put the scripts that create databases and users for mysql?
Sould it be:
I personally think the #1 is better, as we join the different cookbooks under I role anyway.
Edit
It does not concern only databases. For example, I have some applications that require tomcats/jetties/other containers to be installed and configured differently (different ports, different modules enabled). Where different versions of settings.xml/jetty.xml etc. should be stored? In cookbook that
Upvotes: 4
Views: 948
Reputation: 5821
This problem seems to be screaming out for you to use an environment and then have different data bag entries based on environment.
I would place these servers in the appropriate environment, matching the settings they have.
Alternately, the proposal you have around roles also makes sense.
Upvotes: 0
Reputation: 3292
I would suggest including the Opscode database cookbook which provides a LWRP for managing databases and database users.
Next, I would suggest creating one generic cookbook that leverages the LWRPs for databases and data bags. The data bags will hold your configuration information and will isolate your per server configuration differences.
This will allow you to define your data for each server (users, databases, etc) and write one cookbook that can pull in the data and use it.
Also, check out the encrypted data bags which allows you to store your passwords in an encrypted form on your Chef server.
Upvotes: 5