diff options
author | Jon Cowie <jonlives@gmail.com> | 2018-03-01 11:28:11 +0000 |
---|---|---|
committer | Jon Cowie <jonlives@gmail.com> | 2018-03-01 11:28:11 +0000 |
commit | 9209b0b0027971cf6bbd511ad67218774c4e615b (patch) | |
tree | af88a4042faf9571bfd5edd450caa8986fd2381d /lib/chef/policy_builder | |
parent | d857de24b4caab0b8b57e7e4460da7155af261a7 (diff) | |
download | chef-9209b0b0027971cf6bbd511ad67218774c4e615b.tar.gz |
Add attribute hoisting into core
This commit implements RFC-105 and adds specs to verify attribute hoisting is working correctly in conjunction with existing attributes.
Signed-off-by: Jon Cowie <jonlives@gmail.com>
Diffstat (limited to 'lib/chef/policy_builder')
-rw-r--r-- | lib/chef/policy_builder/policyfile.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/chef/policy_builder/policyfile.rb b/lib/chef/policy_builder/policyfile.rb index 545d36cb0e..900abb23cc 100644 --- a/lib/chef/policy_builder/policyfile.rb +++ b/lib/chef/policy_builder/policyfile.rb @@ -263,6 +263,19 @@ class Chef def apply_policyfile_attributes node.attributes.role_default = policy["default_attributes"] node.attributes.role_override = policy["override_attributes"] + policy_group = (defined?(node.policy_group) && node.policy_group) || \ + Chef::Config[:policy_group] || \ + (Chef::Config[:deployment_group] && Chef::Config[:deployment_group].split(/-/).last) + hoist_policyfile_attributes(policy_group) if policy_group + end + + # @api private + # + # Hoists attributes from role_X[policy_group] up to the equivalent role_X level + def hoist_policyfile_attributes(policy_group) + Chef::Log.debug("Running attribute Hoist for group #{policy_group}") + Chef::Mixin::DeepMerge.hash_only_merge!(node.role_default, node.role_default[policy_group]) if node.role_default.include?(policy_group) + Chef::Mixin::DeepMerge.hash_only_merge!(node.role_override, node.role_override[policy_group]) if node.role_override.include?(policy_group) end # @api private |