OSDN Git Service

removes an extra attribute.
[metasearch/grid-chef-repo.git] / data_bags / README.md
1 Data Bags
2 ---------
3
4 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.
5
6 First, create a directory for the data bag.
7
8     mkdir data_bags/BAG
9
10 Then create the JSON files for items that will go into that bag.
11
12     $EDITOR data_bags/BAG/ITEM.json
13
14 The JSON for the ITEM must contain a key named "id" with a value equal to "ITEM". For example,
15
16     {
17       "id": "foo"
18     }
19
20 Next, create the data bag on the Chef Server.
21
22     knife data bag create BAG
23
24 Then upload the items in the data bag's directory to the Chef Server.
25
26     knife data bag from file BAG ITEM.json
27
28
29 Encrypted Data Bags
30 -------------------
31
32 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.
33
34     openssl rand -base64 512 > secret_key
35
36 You may use this secret_key to add items to a data bag during a create.
37
38     knife data bag create --secret-file secret_key passwords mysql
39
40 You may also use it when adding ITEMs from files,
41
42     knife data bag create passwords
43     knife data bag from file passwords data_bags/passwords/mysql.json --secret-file secret_key
44
45 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,
46
47     {
48       "id": "mysql",
49       "password": "abc123"
50     }
51
52 Without the secret_key, the contents are encrypted.
53
54     knife data bag show passwords mysql
55     id:        mysql
56     password:  2I0XUUve1TXEojEyeGsjhw==
57
58 Use the secret_key to view the contents.
59
60     knife data bag show passwords mysql --secret-file secret_key
61     id:        mysql
62     password:  abc123
63