summaryrefslogtreecommitdiff
path: root/lib/chef/policy_builder
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2018-03-09 13:37:18 +0000
committerThom May <thom@chef.io>2018-03-09 13:37:18 +0000
commita09fa9c514539a49edd7115917aa79d4ad49976f (patch)
treed6ed49d3f0758c584d3fe4d4b2bbcc0b609d3417 /lib/chef/policy_builder
parent27de91563e5311cf17fdb53e7542db553787ec2f (diff)
downloadchef-a09fa9c514539a49edd7115917aa79d4ad49976f.tar.gz
RFC 106: expose name and chef_environment as attrstm/chef_environment
We also now set chef_environment the same as policy group when that's appropriate Signed-off-by: Thom May <thom@chef.io>
Diffstat (limited to 'lib/chef/policy_builder')
-rw-r--r--lib/chef/policy_builder/policyfile.rb6
1 files changed, 6 insertions, 0 deletions
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