Forum: Ruby on Rails How do I use Chef to manage database parameters?

99713a5ec23b5195250c9910eb13f01f?d=identicon&s=25 Jason Hsu, Rubyist (Guest)
on 2013-11-08 06:56
(Received via mailing list)
As you know, the correct database name, username, and password in
config/database.yml are needed for a Rails site to work.  I understand
the elegant way to provide these parameters is to use the Chef tool.
However, I can't figure out how to do this.  I'll explain the solution
using instead:
1.  I have an Rails site called Bargain Stock Funds
(  The source code is at .
2.  The config directory of my site's source code has a
database.yml.template file instead of a database.yml file.  The database
name is stored in the settings/db_name.txt file.  The config/update.rb
copies the config/database.yml.template file to config/database.yml and
then uses my bsf_scrape Ruby gem to provide the database name, username,
and password.
3.  The source code of my bsf_scrape gem is at .  This uses my database_params
Ruby gem ( to record the
database name and read the database name, username, and password.  In
development environment, the database username is the same as the UNIX
system username, and there is no password.  In the production
the database username and password are stored in files outside the

I realize that many of you probably consider my database management
solution to be crude.  (Believe it or not, it was even cruder without
use of my database_params and string_in_file Ruby gems.)  However, the
documentation for Chef is so complicated, the the examples I've read
like they're for much more complicated setups than what I have.

Can someone shed some light on how I can transition my app to use Chef?
can't do away with something crude that works until I have a viable
Fcd85a1b175624621cf2ed0cd0616b37?d=identicon&s=25 Emil S. (emil_s)
on 2013-11-08 09:31
(Received via mailing list)
Chef has this thing called DataBags ( ) . You can use the
command to set the database password from your workstation. All the
which are registered with the server should be able to search the data
and retrieve the password.

- Emil Soman
99713a5ec23b5195250c9910eb13f01f?d=identicon&s=25 Jason Hsu, Rubyist (Guest)
on 2013-11-10 08:31
(Received via mailing list)
Thanks, but I still don't understand how to use chef.

Let's say that I'm using PostgreSQL for my database, and the name of the
database is "pg_test1".

Suppose that in my development environment, the database username is
"user1", and the database password is "password1".  In my production
environment, the database name is "pg_test2", the database username is

How would I use Chef and data bags (or solo or something else) to set
parameters for config/database.yml?
Fcd85a1b175624621cf2ed0cd0616b37?d=identicon&s=25 Emil S. (emil_s)
on 2013-11-10 16:03
(Received via mailing list)
Take a look at the chef docs . They have all of this covered in there .
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.