Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Configuration Management with Chef-Solo

You're reading from  Configuration Management with Chef-Solo

Product type Book
Published in Jun 2014
Publisher
ISBN-13 9781783982462
Pages 116 pages
Edition 1st Edition
Languages
Author (1):
Naveed ur Rahman Naveed ur Rahman
Profile icon Naveed ur Rahman
Toc

Data bags


A data bag is a global variable that is stored in JSON and can be accessed by Chef. It is indexed for searching and loaded by chef-client while executing the recipe.

We can use data bags directly in a JSON file or create them using Knife Solo. First, we will use a simpler approach, that is, updating the password with a JSON file.

Before we proceed further, we will create a JSON file under the same folder of Vagrantfile and use this file to run recipes. The benefit of this approach is that Chef-Solo requires a JSON file to execute recipes, and we can test our JSON file with Vagrant. The steps are as follows:

  1. Create your file in the same folder where Vagrantfile exists:

    # wpblog.json
    {
        "wpblog":{
            "db_password": "dbpass1234"
       },
       "run_list": [
            "recipe[wpblog::default]"
        ]
    }
  2. Comment on the add_recipe line in Vagrantfile and add the following code block in Vagrantfile:

    chef.json.merge!(JSON.parse(File.read("wpblog.json")))

    Now, Vagrantfile will look like the following...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime