Gem that allows you to encrypt a Chef Data Bag Item using the public keys of a list of chef nodes. This allows only those chef nodes to decrypt the encrypted values.
Be sure you are running the latest version Chef. Versions earlier than 0.10.0 don't support plugins:
gem install chef
This plugin is distributed as a Ruby Gem. To install it, run:
gem install chef-vault
Depending on your system's configuration, you may need to run this command with root privileges.
See KNIFE_EXAMPLES.md for examples of commands
To set 'client' as the default mode, add the following line to the knife.rb file.
knife[:vault_mode] = 'client'
To set the default list of admins for creating and updating vaults, add the following line to the knife.rb file.
knife[:vault_admins] = [ 'example-alice', 'example-bob', 'example-carol' ]
(These values can be overridden on the command line by using -A)
NOTE: chef-vault 1.0 knife commands are not supported! Please use chef-vault 2.0 commands.
knife vault create VAULT ITEM VALUES knife vault edit VAULT ITEM knife vault refresh VAULT ITEM knife vault update VAULT ITEM VALUES knife vault remove VAULT ITEM VALUES knife vault delete VAULT ITEM knife vault rotate keys VAULT ITEM knife vault rotate all keys knife vault show VAULT ITEM [VALUES]
|-M MODE||--mode MODE||Chef mode to run in. Can be set in knife.rb||solo||"solo", "client"||all|
|-S SEARCH||--search SEARCH||Chef Server SOLR Search Of Nodes||nil||create, remove, update|
|-A ADMINS||--admins ADMINS||Chef clients or users to be vault admins, can be comma list||nil||create, remove, update|
|-J FILE||--json FILE||JSON file to be used for values, will be merged with VALUES if VALUES is passed||nil||create, update|
|nil||--file FILE||File that chef-vault should encrypt. It adds "file-content" & "file-name" keys to the vault item||nil||create, update|
|-p DATA||--print DATA||Print extra vault data||nil||"search", "clients", "admins", "all"||show|
|-F FORMAT||--format FORMAT||Format for decrypted output||summary||"summary", "json", "yaml", "pp"||show|
USAGE IN RECIPES
To use this gem in a recipe to decrypt data you must first install the gem via a chef_gem resource. Once the gem is installed require the gem and then you can create a new instance of ChefVault.
NOTE: chef-vault 1.0 style decryption is supported, however it has been deprecated and chef-vault 2.0 decryption should be used instead
chef_gem "chef-vault" require 'chef-vault' item = ChefVault::Item.load("passwords", "root") item["password"]
USAGE STAND ALONE
chef-vault can be used as a stand alone binary to decrypt values stored in Chef. It requires that Chef is installed on the system and that you have a valid knife.rb. This is useful if you want to mix
chef-vault into non-Chef recipe code, for example some other script where you want to protect a password.
It does still require that the data bag has been encrypted for the user's or client's pem and pushed to the Chef server. It mixes Chef into the gem and uses it to go grab the data bag.
chef-vault --help for all available options
Example usage (password)
chef-vault -v passwords -i root -a password -k /etc/chef/knife.rb
License and Author:
Author:: Kevin Moser - @moserke
Author:: Eli Klein - @eliklein
Author:: Joey Geiger - @jgeiger
Author:: Joshua Timberman - @jtimberman
Copyright:: Copyright (c) 2013 Nordstrom, Inc.
License:: Apache License, Version 2.0
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.