Git Product home page Git Product logo

bag_config's Introduction

BagConfig

Making data bag entries the "last mile" of attribute overrides.

What's it do?

This cookbook allows attributes to be provided via data bag entries. It slips functionality into recipes seamlessly to provide consistent functionality across all recipes, not just those explicitly built for it.

Repository

https://github.com/hw-cookbooks/bag_config

Basic Usage

Access attributes the same way as always:

  • node[:my_cookbook][:my_attribute]

Naming scheme

Data bags

The name of the data bag used will correspond to the name of the base attribute key used within a cookbook. For example, the base attribute key for the munin cookbook is munin thus the data bag name used will be munin. However, the chef-client cookbook uses the base attribute key of chef_client so the data bag name it uses will be chef_client.

The naming of the data bag entries are based on the node name with a config_ prefix. Given a node named lucid, the data bag entry id would be config_lucid. Periods are replaced with underscores within the node name for generating the data bag entry name. Thus, a node named lucid.example.com would have a data bag entry id of config_lucid_example_com.

Quick Ref:

cookbook: chef-client
base key: chef_client
node name: test1.box
data bag name: chef_client
data bag entry id: config_test1_box

Advanced Usage

Custom Data Bag

Example: Use the myconfig data bag to supply configuration entries for the nagios attribute:

  • node[:bag_config][:nagios] = {:bag => :myconfig}

Custom Data Bag Entry

Example: Use custom_config data bag entry id under the nagios base attribute key:

  • node[:bag_config][:nagios] = {:item => 'custom_config'}

Encrypted Data Bag Entry

Encrypted data bags are supported when the encrypted attribute is set:

  • `node[:bag_config][:nagios] = {:encrypted => true}

This will require the secret being provided either inline:

  • node[:bag_config][:nagios] = {:secret => 'my_secret'}

or as a path to the secret file on the node:

  • node[:bag_config][:nagios] = {:secret => '/etc/config_secret.file'}

Allowing/Restricting lookups

By default, the every base attribute key used will invoke an attempt to load a configuration data bag item related to that key. To help reduce the number of lookups required on a run, whitelisting and blacklisting on keys is available:

  • node[:bag_config][:bag_whitelist] = [:nagios, :djbdns]
  • node[:bag_config][:bag_blacklist] = [:nginx, :apache]

NOTE: The blacklist will always have precedence. This means that if an item has been specified in the whitelist and is also found in the blacklist, it will be blacklisted.

Compatibility Note

This version is incompatible with the 1.x versions. It removes all custom methods from Recipe instances and instead proxies the attribute requests via the node, so no modifications are required for full support.

bag_config's People

Contributors

chrisroberts avatar gregsymons avatar josephholsten avatar tas50 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.