Reader small image

You're reading from  Mastering Chef

Product typeBook
Published inJun 2015
Reading LevelIntermediate
Publisher
ISBN-139781783981564
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Mayank Joshi
Mayank Joshi
author image
Mayank Joshi

Mayank Joshi works for Indix as a DevOps engineer. He has worn many hats during his 10-year long career. He has been a developer, a systems analyst, a systems administrator, a software consultant, and for the past 6 years, he has been fascinated with the phenomenal growth witnessed in cloud environments and the challenges of automation associated with the hosting of the infrastructure in such environments. Prior to Indix, he worked for start-ups such as SlideShare, R&D organizations such as CDAC, and even had a stint at a highly automated chemical plant of IFFCO.
Read more about Mayank Joshi

Right arrow

Data bags


A data bag is a global variable that's stored as JSON data and is accessible from a Chef server or chef-solo. A Chef server indexes a data bag, and hence it can be searched using Chef API. Recipes can also search a data bag and access its items.

A data bag has the following structure:

{
  "id": "item_name",
   "key_1": "value_1",
    . . .
    "key_n": "value_n"
}

Before an item can be uploaded to a data bag, a directory structure needs to be put in place to store the JSON files. In chef-repo, create a directory structure as follows:

chef-repo
|-- cookbooks
|-- data_bags
|-- environments
'-- roles

All the data bags will get stored in the data_bags directory. Let's say we've a data bag called users that will be used to store information such as the name, SSH key, and home directory of different users. This will require us to create a directory structure as follows:

chef-repo/data_bags
|-- users

All the JSON files corresponding to different users will go inside this directory.

Management...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Mastering Chef
Published in: Jun 2015Publisher: ISBN-13: 9781783981564

Author (1)

author image
Mayank Joshi

Mayank Joshi works for Indix as a DevOps engineer. He has worn many hats during his 10-year long career. He has been a developer, a systems analyst, a systems administrator, a software consultant, and for the past 6 years, he has been fascinated with the phenomenal growth witnessed in cloud environments and the challenges of automation associated with the hosting of the infrastructure in such environments. Prior to Indix, he worked for start-ups such as SlideShare, R&D organizations such as CDAC, and even had a stint at a highly automated chemical plant of IFFCO.
Read more about Mayank Joshi