Skip to content

Instantly share code, notes, and snippets.

@joelhandwell
Created October 16, 2015 23:19
Show Gist options
  • Save joelhandwell/8d8fe976618a41a1970c to your computer and use it in GitHub Desktop.
Save joelhandwell/8d8fe976618a41a1970c to your computer and use it in GitHub Desktop.
Create encrypted data bag locally with chefdk
$ chef --version
Chef Development Kit Version: 0.6.2
$ openssl rand -base64 512 > /tmp/encrypted_data_bag_secret
$ chef generate repo test_repo
$ cd test_repo
$ mkdir -p data_bags/passwords
$ ls data_bags
README.md example passwords
$ echo "{\n \"id\": \"sql_server_root_password\",\n \"password\": \"learnchef_mysql\"\n}" >> data_bags/passwords/sql_server_root_password.json
$ cat data_bags/passwords/sql_server_root_password.json
{
"id": "sql_server_root_password",
"password": "learnchef_mysql"
}
$ knife data bag from file passwords sql_server_root_password.json --secret-file /tmp/encrypted_data_bag_secret --local-mode
WARNING: No knife configuration file found
Updated data_bag_item[passwords::sql_server_root_password]
$ cat data_bags/passwords/sql_server_root_password.json
{
"id": "sql_server_root_password",
"password": {
"encrypted_data": "Gk0FRcdvnc/RqtN2Iou37ujnzW6HxPyUiJs7tEl1laUdCppyUHjCk/Sh1jic\nhEYT\n",
"iv": "ZC5tGFLGC+cnvXvOq11alw==\n",
"version": 1,
"cipher": "aes-256-cbc"
}
}%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment