Skip to content

A Chef cookbook for writing text-based configuration files in many formats.

License

Notifications You must be signed in to change notification settings

bloomberg-cookbooks/rc

Repository files navigation

rc-cookbook

Cookbook Version License

Library cookbook which provides a resource for writing runtime configuration files.

A runtime configuration file can come in many flavors, but ultimately the purpose is to manage them using a simple resource. The only type which is provided by default is a bash runtime configuration which is simply a key-value pair.

Basic Usage

This cookbook supports several different formats for writing out runtime configuration files from a Ruby Hash object.

Writing bashrc skeleton

The example which is used for testing purposes is writing out an bashrc skeleton file which manages HTTP proxies.

rc_file '/etc/skel/bashrc' do
  type 'bash'
  options(
    'http_proxy' => 'http://proxy.corporate.com:80',
    'https_proxy' => 'http://proxy.corporate.com:443',
    'ftp_proxy' => 'http://proxy.corporate.com:80',
    'no_proxy' => 'localhost,127.0.0.1'
  )
end

Writing Berkshelf configuration

Additionally, this resource supports writing out standard configuration file types such as JSON, YAML and EDN. The example below shows to write out a Berkshelf configuration file in the JSON format.

rc_file '/etc/skel/berkshelf.json' do
  type 'json'
  options(
    'cookbook' => {
      'copyright' => 'Bloomberg Finance L.P.',
      'email' => '[email protected]',
      'license' => 'apachev2'
    }
  )
end

Writing custom configuration

Any new types can be added by modifying the resource (adding a type) and writing the appropriate erb template. If you do not wish to send a PR or fork this cookbook, you can use 'custom' as your type, but you must pass in your own cookbook and source template.

About

A Chef cookbook for writing text-based configuration files in many formats.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •