SousChef

A set of helpers for chef

NOTE: This work is on it's early days and is still under development

What sort of helpers?

For dynamic configuration

  • SousChef::Config.compile_attribute
  • SousChef::Config.compile_attribute_hash

For hashes

souschef/lib/souschef/hash_extensions.rb

Extends Hash class adding .access which doesn't differentiate between string and symbol key and deep_merge from this gem.

About the config compile_attribute_hash

Parses a hash replacing propprop.subpropprop.subprop.subsub tokens by it's values

Usage:

  • Reference other properties using dot-notation sitesite.certssite.certs.root
  • Use a :default key to define default values
  • Use an :items key to define the items to create using the default values
  • :key and :item keys only exist inside default
  • Overwrite defaults by adding a key with the same name of the item

Example:

default[:app] = {
  name: 'myapp',
  user: 'appuser',
  certs: {
    root: '/etc/ssl/certs/{name}',
    cert: '{certs.root}/cert.pem'
  },
  envs: {
    __default__: {
      name: '{__key__}',
      debug: true
    },
    __items__: ['dev', 'staging', 'prod'],
    prod: {
      debug: false
    }
  }
}