I have several recipes in my cubrid cookbook which I use to install CUBRID Database on a Vagrant box. Each recipe has its own attributes file. Eg:
# attributes/default.rb for recipe/default.rb
default['cubrid']['home'] = "/opt/cubrid"
Then:
# attributes/demodb.rb for recipe/demodb.rb
set['cubrid']['demodb_dir'] = "#{node['cubrid']['home']}/databases/demodb"
Then in my recipe/demodb.rb I refer to its attributes like:
include_recipe "cubrid"
CUBRID_DEMODB_DIR = "#{node['cubrid']['demodb_dir']}"
# create a "demodb" directory if it doesn't exist
directory "#{CUBRID_DEMODB_DIR}" do
user "vagrant"
action :create
not_if "test -d #{CUBRID_DEMODB_DIR}"
end
The above should create /opt/cubrid/databases/demodb directory. But it fails, because it tries to create /databases/demodb directory, meaning #{node['cubrid']['home']} was not set.
How do I correctly reference the attributes set in the parent attributes file?