- From: Noah Kantrowitz <
>
- To:
- Subject: [chef] Re: application_ruby database block and attributes
- Date: Wed, 10 Jul 2013 10:25:36 -0700
On Jul 10, 2013, at 10:19 AM, Cassiano Leal wrote:
>
Hi,
>
>
How do I pass parameters (preferably via attributes) to the database block
>
in the application_ruby cookbook?
>
>
What I want to do is something like:
>
>
application “my_app” do
>
...
>
rails do
>
...
>
database do
>
username node[:my_app][:db_user]
>
password node[:my_app][:db_password]
>
end
>
end
>
end
>
>
It looks like the database block does not have access to the node object.
>
>
I have the application resource inside a definition, so I also tried to
>
pass parameters to it, like params[:db_user], but that does not work either.
>
>
How do I set those database parameters dynamically?
Its an issue with Ruby's method lookup order. Outside of that block (I
usually just do it at the top of the file) do "blah = node[:my_app]" and then
in the block you can do "username blah[:db_user]" and whatnot since then it
knows that blah is a variable and not a method call :-( method_missing, got
to love it!
--Noah
Attachment:
signature.asc
Description: Message signed with OpenPGP using GPGMail
Archive powered by MHonArc 2.6.16.