As you know, the correct database name, username, and password in config/database.yml are needed for a Rails site to work. I understand that 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 I’m using instead:
- I have an Rails site called Bargain Stock Funds (http://www.bargainstockfunds.com). The source code is at https://github.com/jhsu802701/bsf .
- 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 file 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.
- The source code of my bsf_scrape gem is at https://github.com/jhsu802701/bsf_scrape . This uses my database_params Ruby gem (https://github.com/jhsu802701/database_params) to record the database name and read the database name, username, and password. In the development environment, the database username is the same as the UNIX system username, and there is no password. In the production environment, the database username and password are stored in files outside the source code.
I realize that many of you probably consider my database management solution to be crude. (Believe it or not, it was even cruder without the 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 sound 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? I can’t do away with something crude that works until I have a viable replacement.