Skip to content

[design-proposal] Add ability to set attributes based on channel or policy_group #154

Open

Description

@emachnic

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

Activity

  1. emachnic commented on Sep 17, 2019

    @emachnic
    ContributorAuthor

    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']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design ProposalCommunity survey of a proposal

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions