I am trying to use a local variable in an included file. I get the error that's it's not defined. I am not sure a way to do this, do you? I have a recipe folder with:
recipes/
development.rb
testing.rb
config.rb
development.rb
username = "vagrant"
static = []
django = ["project1", "project2"]
include_recipe "server::config" # <-- Trying to use static and django in there.
config.rb
static.each do |vhost| # <-- How do I get the "static" var in here?
...
end
django.each do |vhost| # <-- How do I get the "django" var in here?
...
end
Best Answer
You can't share variables between recipes, but there are two ways to share data between recipes.
static
anddjango
as attributes inattributes/default.rb
. This means they'll become available on thenode
object and accessible from each recipe.attributes/default.rb
recipes/config.rb
My suggestion is to definitely stick with option one, it's the most common approach. Hope that helps!