Q about accessing variables from other recipe and splitting attribute files by folders

Hello.

I would be grateful if you answer a couple questions.

  1. Is it possible to access variables defined in one recipe from the other? For example:

cookbooks/cookbook_name/default.rb:
foo = :bar

cookbooks/cookbook_name/somerecipe.rb:
template syspath do
source repopath
variables( :params => foo )
end

  1. Is it possible to load attributes from files located in subdirectory of attribute folder? For example:

cookbooks/
|-cookbook_name/
||-attributes/
||-default.rb
|||-attribute_folder1/
||||-one_more_attribute_file.rb
|||-attribute_folder2/
||||-one_more_attribute_file.rb

Thanks in advance, Daniil.

Correction of the 1st question: ‘default’ recipe contains ‘include’ of ‘somerecipe’:

cookbooks/cookbook_name/default.rb:
foo = :bar
include ‘cookbook_name::somerecipe’

cookbooks/cookbook_name/somerecipe.rb:
Chef::Log.info(foo)
template syspath do
source repopath
variables( :params => foo )
end

So I think there certainly should be some way to access variable.

Thanks in advance, Daniil.

 пятница, 7 ноября 2014 17:22 Daniil S <daniil_sb@yahoo.com> писал(а):

Hello.

I would be grateful if you answer a couple questions.

  1. Is it possible to access variables defined in one recipe from the other? For example:

cookbooks/cookbook_name/default.rb:
foo = :bar

cookbooks/cookbook_name/somerecipe.rb:
template syspath do
source repopath
variables( :params => foo )
end

  1. Is it possible to load attributes from files located in subdirectory of attribute folder? For example:

cookbooks/
|-cookbook_name/
||-attributes/
||-default.rb
|||-attribute_folder1/
||||-one_more_attribute_file.rb
|||-attribute_folder2/
||||-one_more_attribute_file.rb

Thanks in advance, Daniil.