Forum: Ruby on Rails Using Chef to set the database name, username, and password

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
99713a5ec23b5195250c9910eb13f01f?d=identicon&s=25 Jason Hsu, Rubyist (Guest)
on 2013-11-01 18:59
(Received via mailing list)
One of my Ruby on Rails apps is Bargain Stock Funds
(, and it relies on a Ruby gem called
bsf_scrape ( to obtain and
data on stock funds and then save the results in a PostgreSQL database.

As you well know, the config/database.yml file needs the database name,
username, and the password. My procedures for handling this work but are
clunky and probably not considered to be best practices. From what I've
heard, using Chef is the best practice. However, Chef is complicated,
I'm having difficulty making sense of it.

In the source code for bsf_scrape (Ruby gem), I have functions in the
lib/bsf_scrape.rb file that do the following:
1.  Set the database name (stores it in a file)
2.  Get the database name (read it from a file)
3.  Set the path to the directory containing the username and password
(necessary for the production environment, as the database username is
different from the server username): Please note that while the database
name is the same in the development and production environments, the
username and password are different.
4.  Get the path to the directory containing the username and password
(production environment)
5.  Reads the username from a file (production environment)
6.  Reads the password from a file (production environment)

In the source code for bsf (Rails app), I have procedures that obtain
database parameters during the deployment process. Running the
script (config/deploy.rb) involves running the update script
(config/update.rb), that provides the database name, database username,
database password and retains these parameters in files for use by the
bsf_scrape Ruby gem.

I know this process is convoluted, but I can't replace it until I figure
out how to do it correctly in Chef. Are there any good Chef
tutorials/examples that will help me with this? My needs aren't that
complex at the moment, but most of the tutorials/examples I've looked at
This topic is locked and can not be replied to.