Skip to content

Commit b5713a2

Browse files
committed
Added encrypted data bags documentation
1 parent cf7ad13 commit b5713a2

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

data_bags/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Data Bags
2+
---------
13
This directory contains directories of the various data bags you create for your infrastructure. Each subdirectory corresponds to a data bag on the Chef Server, and contains JSON files of the items that go in the bag.
24

35
First, create a directory for the data bag.
@@ -21,3 +23,39 @@ Next, create the data bag on the Chef Server.
2123
Then upload the items in the data bag's directory to the Chef Server.
2224

2325
knife data bag from file BAG ITEM.json
26+
27+
28+
Encrypted Data Bags
29+
-------------------
30+
Added in Chef 0.10, encrypted data bags allow you to encrypt the contents of your data bags. The content of attributes will no longer be searchable. To use encrypted data bags, first you must have or create a secret key.
31+
32+
openssl rand -base64 512 > secret_key
33+
34+
You may use this secret_key to add items to a data bag during a create.
35+
36+
knife data bag create --secret-file secret_key passwords mysql
37+
38+
You may also use it when adding ITEMs from files,
39+
40+
knife data bag create passwords
41+
knife data bag from file passwords data_bags/passwords/mysql.json --secret-file secret_key
42+
43+
The JSON for the ITEM must contain a key named "id" with a value equal to "ITEM" and the contents will be encrypted when uploaded. For example,
44+
45+
{
46+
"id": "mysql",
47+
"password": "abc123"
48+
}
49+
50+
Without the secret_key, the contents are encrypted.
51+
52+
knife data bag show passwords mysql
53+
id: mysql
54+
password: 2I0XUUve1TXEojEyeGsjhw==
55+
56+
Use the secret_key to view the contents.
57+
58+
knife data bag show passwords mysql --secret-file secret_key
59+
id: mysql
60+
password: abc123
61+

0 commit comments

Comments
 (0)