[design-proposal] Add ability to set attributes based on channel or policy_group
Add ability to set attributes based on channel or policy_group
This is to formalize the design proposal discussed in #101. For effortless, it would be great to have the ability to specify different attributes based on channel or policy_group
Motivation
As a Habitat node running Chef Infra effortless,
I want to use different attribute values when in a different channel or policy_group,
so that I can write configs with different, dynamic values.
Specification
Currently, one way of writing different config values is by setting the values based on policy_group. These can be set in the Policyfile.rb and then hoisted to the top level. It would be great to be able to do this in effortless config to make it easier to transition. One option could be to utilize the channel that Habitat is subscribed to and somehow switch on that. Refer to #101 for further discussion on this.
Downstream Impact
Should only impact effortless config
I was thinking about this a bit and if there was a way to read the Habitat channel that the node is subscribed to from the Chef recipe, then this would probably work pretty easily. I could see having Habitat set an env var, maybe HAB_CHANNEL, and then using that in the Policyfile and recipe like:
# This assumes the Habitat channels "qa" and "prod"
# Policyfile.rb
default['qa']['myattribute'] = '<qa_value>'
default['prod']['myattribute'] = '<prod_value>'
# default.rb
myattribute_value = node["#{ENV['HAB_CHANNEL']}"]['myattribute']