-
-
Save patmaddox/9633594 to your computer and use it in GitHub Desktop.
default_attributes chef_user: "ubuntu" | |
default_attributes { ... a whole mess of other stuff which apparently blows away the first line. whoops } |
when recipes_rbenv.rb is loaded, node['chef_user'] is nil. However I can see a | |
chef_user attribute if I look at the node information on the chef server. I've | |
also tried passing {'chef_user' => 'ubuntu'} to default_attributes in case it | |
was a problem with string vs symbol for the key. No luck. Any ideas how I can | |
get the value of this attribute that's set in the environment's default_attributes? |
node.default['rbenv']['user_installs'] = [ | |
{'user' => node['chef_user'] } | |
] |
I would guess that the recipe compile time is evaluating before the attributes from the environment are available for some reason, although that's not obvious according to the attribute precedence page. sorry~ :)
is there some reason you can't have this in an attributes file?
default['rbenv']['user_installs']['user'] = node['chef_user'] if node.key? 'chef_user'
Or simply specify rbenv.user_installs.user in your environment dsl? :)
thanks for the reply @fujin
well I reference chef_user a bunch of places, including in my own templates. I'm pretty confused because I thought this worked just fine when I did a knife bootstrap and along with a couple other chef-client updates, but now it's not working. I'm under the impression that chef can't / shouldn't just stop working like that so I'm not really sure what's going on.
But anyway yeah there are like 15 references to chef_user in other recipes, so I do need to sort out how to get the recipe to read the attribute as set in the environment.
here's what I get when I include puts node.debug_value(:chef_user)
in the recipe. Not sure what I'm looking for to tell you the truth…
set_unless_enabled?
false
default
not_present
env_default
not_present
role_default
not_present
force_default
not_present
normal
not_present
override
not_present
role_override
not_present
env_override
not_present
force_override
not_present
automatic
not_present
okay got it sorted, you can't call default_attributes twice in an environment file, the second call will blow away the first one
try out 'log node.debug_value(:chef_user)' or similar.