-
-
Save StFS/2a333afe352d0dc8cbb5 to your computer and use it in GitHub Desktop.
Chef attribute file problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
default["rda"]["user"] = 'rda' | |
default['rda']['home_dir'] = "/home/#{node.rda.user}" | |
raise node.rda.inspect | |
default['rda']['home_env_dir'] = "#{node.rda.home_dir}/env/dev" | |
# This throws a runtime error (due to the 'raise' line) with the output: {"user"=>"rda"} | |
# So it never adds anything after attempting to create the rda.home_dir value | |
# but Chef does not throw an error itself, it only happens because I have a raise in there. | |
#---------------- | |
# So I tried to move the 'raise' line down one line: | |
default["rda"]["user"] = 'rda' | |
default['rda']['home_dir'] = "/home/#{node.rda.user}" | |
default['rda']['home_env_dir'] = "#{node.rda.home_dir}/env/dev" | |
raise node.rda.inspect | |
# This results in the error: Undefined method or attribute `home_dir' on `node' | |
# so the execution now never reaches the 'raise' line. | |
#---------------- | |
# So now I tried hard coding all values instead of depending on previous attributes: | |
default["rda"]["user"] = 'rda' | |
default['rda']['home_dir'] = "/home/rda" | |
default['rda']['home_env_dir'] = "/home/rda/env/dev" | |
raise node.rda.inspect | |
# This appears normal. Of course the 'raise' results in an error but the message | |
# I get is an attribute map that I was expecting: | |
# {"user"=>"rda", "home_dir"=>"/home/rda", "home_env_dir"=>"/home/rda/env/dev"} | |
# If I remove the raise line, the execution continues until it encounters the next | |
# attribute that depends on an attribute that depends on an attribute! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment