Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

Select Status

RSS

common_attrs (12) Versions 0.1.6

Resourced to help manage Chef attributes

Policyfile
Berkshelf
Knife
cookbook 'common_attrs', '= 0.1.6', :supermarket
cookbook 'common_attrs', '= 0.1.6'
knife supermarket install common_attrs
knife supermarket download common_attrs
README
Dependencies
Changelog
Quality 0%

common_attrs cookbook

A cookbook which provides tools (libraries, custom resources) to help manage Attributes during Chef runs. This is especially useful when using PolicyFiles which require a workflow to replace the concept of Environments.

Be advised that this cookbook provides you with all of the necessary tools to shoot yourself in the foot ... repeatedly ... so much so that you may end up a bloody mess. When making use of any of the Custon Resources contained within, you should be sure to have a workflow in mind.

Requirements

This cookbook required Chef 12.7.0 or later.

Platform

Any

Documentation

Comments will be found throughout the attribute, resource and library files
so that the documentation and code are more closely linked. What's found in
this Readme will be more of a high-level overview.

Custom Resources

common_environment

Resource which will load a data_bag_item and apply it's contents onto the node at either the environment or role precedence levels during compile time. The format of this file should be mostly identical to existing environment files, with only the default_attributes and override_attributes keys being honored.

A recipe, common_attrs::environments, also exists which will iterate through config[:common_attrs][:environments][:active][:prepend] and create a common_environment for each of : node.environment, node.policy_group, node.policy_name.

The recipe will then loop through config[:common_attrs][:environments][:active][:custom], creating whatever further common_environment resources are required.

common_namespae

Resource which will take a Hash-ish node attribute and merge it onto the node at the environment precedence level. This allows you to set attribute overrides for a given environment, policy_group or policy_file in a centralize location.

A recipe, common_attrs::namespaces, also exists which will iterate through config[:common_attrs][:namespaces][:active][:prepend] and create a common_namespace for each of : node.namespace, node.policy_group, node.policy_name.

The recipe will then loop through config[:common_attrs][:namespaces][:active][:custom], creating whatever further common_namespace resources are required.

common_secrets

Resource which will load a data_bag_item containing secrets into the node.run_state if it has not already been created. This may then be used by other resources, such as common_secret or directly within your recipes.

common_secret

Resource which will load a secret from common_secret and apply it's value to a node attribute at compile time. In addition, the attribute path will be registered to node[:common_attrs][:obfuscated] so that it's value is wiped prior to reporting to Chef server.

Recipes

  • default: Load allofthethings
  • environments: Load common_environment from attributes
  • namespaces: Load common_namespace from attributes
  • secrets: Load common_secret from attributes
  • obfuscated: Register a Chef Event handler to obfuscate attributes at the end of the converge phase.
  • blacklisted: Register a Chef Event handler to delete attributes at the end of the converge phase.

Library Methods

This cookbook provides a number of helper methods and injects a few of them by monkey patching DataBagItem, Node::Atributes and Resource. When doing this, special care is taken to ensure that the method names are namespaced so as to minimize future WTF moments.

Documentation on each of these may be found within the library files.

  • Hash.dig
  • Hash.common_assign_at
  • Resource.common_properties
  • DataBagItem.to_common_data
  • DataBagItem.to_common_namespace
  • EncryptedDataBagItem.to_common_data
  • EncryptedDataBagItem.to_common_namespace
  • Attribute.to_common_data
  • Attribute.to_common_namespace
  • Comon::Delegator::ObfuscatedType

Attribute Precedence

Given that we're dealing with Attributes, special care needs to be taken to ensure that we don't get lost in the myriad of different precedence levels.

new? source precedence level
no cookbook.attribute default
no cookbook.recipe default
no environment environment_default
yes common_environment environment_default
yes common_namespace environment_default
no role role_default
no policy_file role_default
yes common_secrets force_default
no cookbook.attribute normal
no cookbook.recipe normal

common_attrs

0.1.5

  • Add attribute blacklisting
  • Add whyrun support/bypass to all common_attr resources

0.1.4


  • Add EncryptedDataBagItem monkey patches

Foodcritic Metric
            

0.1.6 failed this metric

FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/attributes/common_attrs-blacklist.rb:21
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/attributes/common_attrs-environments.rb:2
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/attributes/common_attrs-namespaces.rb:2
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/attributes/common_attrs-obfuscated.rb:21
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/attributes/common_attrs-secrets.rb:2
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/libraries/common-mixin-namespaced_hash.rb:11
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/libraries/common-mixin-namespaced_hash.rb:16
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/libraries/common-mixin-namespaced_hash.rb:17
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/recipes/blacklisted.rb:11
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/recipes/environments.rb:2
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/recipes/environments.rb:8
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/recipes/namespaces.rb:2
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/recipes/namespaces.rb:8
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/recipes/obfuscated.rb:15
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/recipes/secrets.rb:2
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/resources/common_environment.rb:28
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/resources/common_environment.rb:39
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/resources/common_environment.rb:44
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/resources/common_namespace.rb:38
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/resources/common_namespace.rb:43
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/resources/common_secret.rb:21
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/resources/common_secret.rb:31
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/resources/common_secret.rb:56
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/resources/common_secret.rb:70
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/resources/common_secrets.rb:17
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/resources/common_secrets.rb:28
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/resources/common_secrets.rb:61
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/resources/common_secrets.rb:62
FC016: LWRP does not declare a default action: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/resources/common_environment.rb:1
FC016: LWRP does not declare a default action: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/resources/common_namespace.rb:1
FC016: LWRP does not declare a default action: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/resources/common_secret.rb:1
FC016: LWRP does not declare a default action: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/resources/common_secrets.rb:1
FC019: Access node attributes in a consistent manner: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/attributes/common_attrs-environments.rb:11
FC019: Access node attributes in a consistent manner: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/attributes/common_attrs-environments.rb:12
FC019: Access node attributes in a consistent manner: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/attributes/common_attrs-namespaces.rb:7
FC019: Access node attributes in a consistent manner: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/attributes/common_attrs-namespaces.rb:8
FC046: Attribute assignment uses assign unless nil: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/attributes/common_attrs-blacklist.rb:21
FC046: Attribute assignment uses assign unless nil: /tmp/cook/ec33b6d2250d5fab2658725d/common_attrs/attributes/common_attrs-obfuscated.rb:21