L20 – Data Bags
A DATABAG is a GLOBAL variable stored in JSON – Java Script Object Notation.
Type of data, e.g.:
User Account information
Sudo users
API / Database schema Credentials
etc
Can be encrypted
e.g. users on a system, sudo users, API/DB Credentials etc{
“id”:”PHH”,
“comment”:”Another User”,
“uid”:”1000″,
“home”:”/home/oracle”,
“shell”,”/bin/bash”
} Set up data_bags directories for our users and our groups data_bags $ cd chef-repo
$ mkdir data_bags
$ cd data_bags
$ mkdir {users,groups}
Set up the wheel sudoers group
$ cd ../groups $ vi sudoers.json { “id”:”wheel”, “gid”:”1000″, “members”:[“phh”] } Â Set up the users data_bag for user phh $ cd users$ vi phh.json
{ “id”:”phh”,
“comment”:”Another User”,
“uid”:”10″,
“gid”:”1000″,
“home”:”/home/oracle”,
“shell”,”/bin/bash”, “password”:”mypwd”
} Â Create the data_bag items $ knife data bag create users Created data_bag[users] Â $ knife data bag create groups Created data_bag[groups]
Go to the WEB and look at the data_bags
-> Policy -> databags
Add the data_bag items
$cd ..
$ knife data_bag from file users phh.json
$ knife data_bag from file groups sudoers.json
Discussion ¬