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: 1. I have an Rails site called Bargain Stock Funds (http://www.bargainstockfunds.com). The source code is at https://github.com/jhsu802701/bsf . 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 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. 3. 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. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/496c2621-05b7-46e9-93a1-548e7528c949%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Chef has this thing called DataBags ( http://docs.opscode.com/essentials_data_bags.html ) . You can use the knife command to set the database password from your workstation. All the nodes which are registered with the server should be able to search the data bag and retrieve the password. - Emil Soman On 8 November 2013 11:25, Jason Hsu, Rubyist <jhsu802701-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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: > 1. I have an Rails site called Bargain Stock Funds ( > http://www.bargainstockfunds.com). The source code is at > https://github.com/jhsu802701/bsf . > 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 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. > 3. 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. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/496c2621-05b7-46e9-93a1-548e7528c949%40googlegroups.com > . > For more options, visit https://groups.google.com/groups/opt_out. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAJ%3Dox-CHvwuGXy5o4nfMOc-%2B3soUhauPFbEPjsfVFw13MbSgTA%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Jason Hsu, Rubyist
2013-Nov-10 07:29 UTC
Re: How do I use Chef to manage database parameters?
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 "password2". How would I use Chef and data bags (or solo or something else) to set these parameters for config/database.yml? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/4a43fb6f-3677-4cbf-8d44-5b3a724a9b16%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Take a look at the chef docs . They have all of this covered in there . On 10 Nov 2013 12:59, "Jason Hsu, Rubyist" <jhsu802701-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 > "password2". > > How would I use Chef and data bags (or solo or something else) to set > these parameters for config/database.yml? > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/4a43fb6f-3677-4cbf-8d44-5b3a724a9b16%40googlegroups.com > . > For more options, visit https://groups.google.com/groups/opt_out. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAJ%3Dox-DrQ2hb9qCOfddc5Z4qmp%3D-FFYj4kTGo%3DpcgVyY%2BQVNhA%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.