A knife plugin to ease working with data bags and chef solo
A knife plugin to ease working with data bags and chef solo
A knife plugin to make working with data bags easier in a chef solo environment.
If you are looking for a full featured chef solo management solution, you may want to check out knife solo.
knife data bagThe standard chef gem includes the knife command and
commands to manipulate data bags.
knife-solo_data_bag has the following advantages over the knife data bag
command:
knife-solo_data_bag = 11.4.0.
If you need support for an earlier version of chef, use a knife solo data bag version = 12.x, you need to indicate that you're running in local mode,
otherwise Chef will try to connect to a server.In .chef/knife.rb, add:
local_mode trueCreate a plain text data bag
$ knife solo data bag create apps app_1Create an encrypted data bag with the provided string as the secret
$ knife solo data bag create apps app_1 -s secret_keyCreate an encrypted data bag with the provided file content as the secret
$ knife solo data bag create apps app_1 --secret-file 'SECRET_FILE'Create a data bag item with JSON from the command line (works with encryption)
$ knife solo data bag create apps app_1 --json '{"id": "app_1", "username": "bob"}'Create a data bag item from a json file
$ knife solo data bag create apps app_1 --json-file foo.jsonEdit a plain text data bag
$ knife solo data bag edit apps app_1Edit an encrypted data bag with the provided string as the secret
$ knife solo data bag edit apps app_1 -s secret_keyEdit an encrypted data bag with the provided file content as the secret
$ knife solo data bag edit apps app_1 --secret-file 'SECRET_FILE'List data bags
$ knife solo data bag listShow the plain text content of a data bag (if this is an encrypted data bag, it will return the encrypted data)
$ knife solo data bag show apps app_1Show the unencrypted content of an encrypted data bag with the provided string as the secret
$ knife solo data bag show apps app_1 -s secret_keyShow the unencrypted content of an encrypted data bag with the provided file content as the secret
$ knife solo data bag show apps app_1 --secret-file 'SECRET_FILE'You can also display any of the above variations in JSON format with -F json
$ knife solo data bag show apps app_1 -s secret_key -F jsonYou can load your data bags inside you recipes as follows:
app_1 = Chef::EncryptedDataBagItem.load("apps", "app_1").to_hashBy default, this plugin will use the configured data_bag_path. This is
defaulted to /var/chef/data_bags by Chef. It is possible to override this
path in your Chef client config if desired. When using this plugin, it is also
possible to override the path using the --data-bag-path argument.
This plugin respects the "encrypted_data_bag_secret" configuration option in knife.rb. Command line secret arguments (-s or --secret-file) will override the setting in knife.rb.
This plugin has been tested on the following:
Chef:
Ruby:
OS:
Running tests requires an indication of the Gemfile to use:
export BUNDLE_GEMFILE=$PWD/gemfiles/Gemfile.chef.11.18.12
bundle
bundle exec rspecSee LICENSE for details
No open issues yet, or sync has not completed.