This is basically just an idea dump. You might notice that there is a lot of unnecessary swearing. Do not enter if you are offended by 4 letter words.
Chef web app developer training - Part 7 (draft)
The purpose of this series of tutorials is to take web app developers through the basic knowledge necessary to create and maintain the cookbooks used to deploy web applications.
The prerequisites for Part 7 are to have a working setcloud configuration for "class01" and your own hosted chef organization e.g. "tomhodder". ("knife cookbook list" etc, should work)
The purpose of Part 7 is to cover "data bags", what they are and how they work.
The data bag itself is a list of json objects that are persisted on the chef-server, and accessible from either knife, or from inside cookbooks using the search() method.
Data bags are for organization general data, and not for the minutia of your app. Typically data bags contain usernames, hostnames, groups, networks. It is not a good idea to put passwords in your data bag.
An important thing to be aware of, is that data bags are READ ONLY for the deployed node. So they are only for data items that are set by a superuser, and consumed by a node instance.
From a Java perspective they are similar to HashMap Collection object like so;
HashMap<String, JsonObject>
e.g. {"attr1": { "attr2":"val2 } }
or as an array of JsonObject;
HashMap<String, JsonObject[]>
{ "array1" : { { "attr1":"val1 } , { "attr2":"val2 }} }
Part 7
======
1) create a data bag using your opscode username;
$ knife data bag create tomhodder
Created data_bag[tomhodder]
2) add an item called tomhodder to your data bag tomhodder;
$ knife data bag create tomhodder tomhodder
{
"id": "tomhodder",
"name": "value"
}
3) list all the data bags on the server;
$ knife data bag list
tomhodder
otherdatabag
4) show the value of the data bag "tomhodder" item with id "tomhodder" in default format
$ knife data bag show tomhodder tomhodder -Ft
id: tomhodder
name: value
5) do the same things but show the output in json format. (this can be piped to other commands)
$ knife data bag show tomhodder tomhodder -Fj
{
"name": "value",
"id": "tomhodder"
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Don't be nasty. Being rude is fine.