diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/node.rb | 17 | ||||
-rw-r--r-- | lib/chef/policy_builder/policyfile.rb | 6 |
2 files changed, 19 insertions, 4 deletions
diff --git a/lib/chef/node.rb b/lib/chef/node.rb index 7b530e1132..496bfedc15 100644 --- a/lib/chef/node.rb +++ b/lib/chef/node.rb @@ -330,6 +330,8 @@ class Chef Chef::Log.debug("Platform is #{platform} version #{version}") automatic[:platform] = platform automatic[:platform_version] = version + automatic[:name] = name + automatic[:chef_environment] = chef_environment end def consume_ohai_data(ohai_data) @@ -421,6 +423,7 @@ class Chef apply_expansion_attributes(expansion) + automatic_attrs[:chef_environment] = chef_environment expansion end @@ -510,7 +513,16 @@ class Chef return o if o.kind_of? Chef::Node node = new node.name(o["name"]) - node.chef_environment(o["chef_environment"]) + + node.policy_name = o["policy_name"] if o.has_key?("policy_name") + node.policy_group = o["policy_group"] if o.has_key?("policy_group") + + unless node.policy_group.nil? + node.chef_environment(o["policy_group"]) + else + node.chef_environment(o["chef_environment"]) + end + if o.has_key?("attributes") node.normal_attrs = o["attributes"] end @@ -525,9 +537,6 @@ class Chef o["recipes"].each { |r| node.recipes << r } end - node.policy_name = o["policy_name"] if o.has_key?("policy_name") - node.policy_group = o["policy_group"] if o.has_key?("policy_group") - node end diff --git a/lib/chef/policy_builder/policyfile.rb b/lib/chef/policy_builder/policyfile.rb index e1293190f8..d479808b4a 100644 --- a/lib/chef/policy_builder/policyfile.rb +++ b/lib/chef/policy_builder/policyfile.rb @@ -164,6 +164,11 @@ class Chef events.node_load_completed(node, run_list_with_versions_for_display, Chef::Config) events.run_list_expanded(run_list_expansion_ish) + # we must do this after `node.consume_external_attrs` + node.automatic_attrs[:policy_name] = node.policy_name + node.automatic_attrs[:policy_group] = node.policy_group + node.automatic_attrs[:chef_environment] = node.policy_group + node rescue Exception => e events.node_load_failed(node_name, e, Chef::Config) @@ -400,6 +405,7 @@ class Chef node.policy_name = policy_name_to_set node.policy_group = policy_group_to_set + node.chef_environment = policy_group_to_set Chef::Config[:policy_name] = policy_name_to_set Chef::Config[:policy_group] = policy_group_to_set |