- From: Jay Buffington <
>
- To:
- Subject: [chef] Are all attribute files included even when their corresponding recipes are not?
- Date: Mon, 25 Apr 2011 22:48:33 -0700
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=BtkpfnrLfU8XJmIZf/X+LyoN0gRQ5656/GRD3ZS0Ttdk9MTilzIUO60OnpHrWoEB+b MvRp0BuPrOe51CWv9qzpX/fCd7q+ag8Gnrhatq72F7MonjrCRcxBQDeYwHLRGgke1Lit 5jGozVCoiVEqg59j8PdKkbPJNhJyyoZO68wvI=
Hi,
I'd like to use chef to setup my database. On some nodes (say,
production) the database is already set up and I don't need to do
anything. On other nodes (say, development) I want to include the
mysql::server recipe, start a new mysql instance and create my
application database.
I tried this in my recipe:
if !node[:mysql][:server_root_password].empty?
mysql_database "create #{node[:app][:database][:name]} database" do
host node[:app][:database][:host]
username "root"
password node[:mysql][:server_root_password]
database node[:app][:database][:name]
action :create_db
end
end
I don't want to include the db root password in my attributes (it's
not needed if the database is already created). I was happy to see
that the mysql::server password generates a root password. I was
expecting node[:mysql][:server_root_password] to only be set when I
included the mysql::server recipe and empty otherwise. To my surprise
it is set, even if I am only using the mysql client recipe.
Is it true that all attribute files are included when only some of the
recipes are used? When a recipe has a name like server.rb is there
any special treatment for an attribute file of the same name? How can
I tell chef to ignore this attribute file unless the server recipe is
being executed?
One solution may be to move the line that generates the password out
of the attributes and into the mysql::server recipe. Is this
reasonable?
Thanks,
Jay
- [chef] Are all attribute files included even when their corresponding recipes are not?, Jay Buffington, 04/25/2011
Archive powered by MHonArc 2.6.16.