Home > automation > Why can't "knife data bag from file" find existing json file on chef server?

Why can't "knife data bag from file" find existing json file on chef server?

October 17Hits:1
Advertisement

Summary:

I'm running into a problem with "knife data bag from file", where knife doesn't recognize the .json data bag file pulled down from a remote git repo.

Background:

I'm currently trying to transition from chef-solo use to chef server while using the cookbooks, data bags and other chef info from our remote git repo.

I've currently pulled down a copy of our git repo and set the cookbook path and data bag path in knife.rb. I also loaded the cookbooks, made adjustments, etc.

Details:

When trying to load our .json data bags by doing "knife data bag add from file FOLDER FILE" it looks like it worked until I do "knife data bag list" and it comes up blank. So I decided to try adding the edit option at the end to see what's being loaded, if it is. This is the error I get:

knife data bag from file local_settings test.json -e nano ERROR: Could not find or open file 'test.json' in current directory or in 'data_bags/local_settings/test.json' 

The data bag file does exist, in the proper location, in a tested, working json file. I've also sometimes gotten an error saying "could not open data bag "local_settings".

I would obviously like to keep the data bag path within the appropriate git repo folder to be able to keep track of changes in a more centralized location (our git repo, as opposed to the chef server).

Any solutions, advice or pointers in the right direction are appreciated.

Answers

I don't think it's valid to use -e nano option knife data bag from file (though the command-line help implies otherwise), but it should just be ignored. That error means that knife can't find the json file you have specified. When you say that the item was in the proper location, where exactly was it? Note that knife will be looking relative to your current directory, not to your chef-repo.

With that problem fixed, you'll run into another - you need to create the data bag before you can add an item to it. It should show up in the knife data bag list output as soon as it has been created:

 $ knife data bag create local_settings
Created data_bag[local_settings]
 $ knife data bag list
  local_settings

The documentation for "knife data bag" can be found here: http://wiki.opscode.com/display/chef/Managing+Data+Bags+With+Knife

I do knife data bag list and it comes up blank.

It means that data bag local_settings is not created yet.

So, it should be created:

$> knife data bag create local_settings
Created data_bag[local_settings]

Then it should appear in list if server's data bags:

$> knife data bag list
  local_settings

Then {{test.json}} data bag file could be uploaded.

Also, here is some nice explanation of what is actually going on: [link on CHEF wiki].

Related Articles

  • Why can't "knife data bag from file" find existing json file on chef server?October 17

    Summary: I'm running into a problem with "knife data bag from file", where knife doesn't recognize the .json data bag file pulled down from a remote git repo. Background: I'm currently trying to transition from chef-solo use to chef server while

  • Knife data bag from file - is not creating encrypted fileDecember 21

    I'm trying to create an encrypted databag. I'm using something like this as source { "id": "rds-2", "web": "adeasdeasde" } and I want the encrypted file to go on to data_bag/aws/rds-2.json, so I'm running: knife dat

  • Node.js : Write new data to an existing json fileFebruary 11

    I'm trying to add data to an existing json file (codes below). When I access the locahost, the new piece of data shows up, however, when I check the data (users.json), the new piece of data (i.e. user4) isn't there. Does anyone know what's wrong with

  • Loading an html/javascript file inside a json fileFebruary 10

    I'm trying to load an html file from my json file as soon as this button is clicked: chrome["browserAction"]["onClicked"].addListener(function() { window.open("http://agar.io/"); }); So, you will click the google chrome exten

  • How to create excel file from existing excel file in SharePoint 2010April 11

    I will have a master excel file stored in one of the SP list. On the button click I have to create new excel file by reading master template and need to modify some cells and store new file in separate SP List. Any help or guidance will be much appre

  • Get list of files(videos)in JSON file from server and download videos on order and than to play it in order also? February 9

    This question already has an answer here: How to send a JSON object over Request with Android? 6 answers I have a web service that stores the files at http://.mysite.com/content/videos Now all I want to achieve in my android application is to downloa

  • Update existing data in a content type from JSON file in DrupalMay 30

    I have to import Latitude and Longitude data in to a Geofield that was added to an existing Content type. Source Info The json feed contains a lot of data fields including the Longitude, Latitude info, Title and a unique ID I tried the following: Fee

  • How can i insert new json object to existing json file (in the middle of object)February 11

    filejson.json {"Fiksi":[ { "judul":"fiksi1", "pengarang":"pengarang1", "file":"namafiksi1.txt" }, { "judul":"fiksi2", "pengarang":"pengarang2", &

  • check if a json file already has the data i am overriding in pythonFebruary 14

    I am currently making a python script that automates a task by sending an email after first parsing the data from a website then sending the message from that data using twilio. But what I want is to first compare the data parsed with the already exi

  • keeping chef data bags on server in sync via git repositoryMarch 15

    I recently started using chef and I love it for provisioning my vagrant boxes and quickly spawning new machinges. Now I started using a hosted chef server. It's pretty easy to manage my cookbooks using Berkshelf with all needed cookbooks distributed

  • Creating a pie highchart from Data in local (OBJECT) JSON fileFebruary 17

    This is my JSON data in my JSON file {"diskspace":100,"diskspace.free":50,"time":8,"time.played":2,"controllers":25,"controllers.used":3, "controllers.new":10, "controllers.broken&

  • opsworks/chef databag where to put the json file?January 23

    Hello I'm reading this howto: https://github.com/imoglobe/opsworks-cookbooks/blob/master/user/README.md but it does not mention where to put the data bag in the cookbook with the list of users in json format.. I have done some searching and answers c

  • Import nested JSON file May 26

    This question already has an answer here: How to switch from List of rules to Association? [duplicate] 5 answers For a project where I receive JSON messages from a web server I was trying to convert these messages into a format that can be used easil

  • Inserting JSON file into MySQL via PHP ScriptJanuary 29

    I am trying to add data from a JSON file into MySQL via php script and I am getting a null array in MySQL and the following errors. I am using xampp lite 1.8 on windp Notice: Undefined variable: tagscolor in C:\xampp\htdocs\jsonreader\index.php on li

  • How to improve this javascript code loading JSON files to be more dynamicJanuary 30

    I'm building a web page with a collection of html tables. The data for each table is stored JSON files and I wrote a JQuery method to load the data and render it into HTML. Currently, this looks like HTML <!-- Load sample_triangles.json into the foll

  • Reading JSON file in Python and detecting specific keywords in field

    Reading JSON file in Python and detecting specific keywords in fieldFebruary 9

    I just started this week to learn Python and I have the following question. I have a JSON file (Aberdeen2015.json) that contains 60 lines (each line containing a newspaper article). Moreover, each line contains a list with the date, title and body of

  • How to read from json file in html page ? February 13

    This question already has an answer here: Access / process (nested) objects, arrays or JSON 6 answers Guys I want to read from json file ,i create json file and use ajax to read from it. i create Video object which contain Courses objects (title & UR

  • Read json file content with require vs fs.readFileFebruary 14

    Suppose that for every response from an API, i need to map the value from the response to an existing json file in my web application and display the value from the json. What are the better approach in this case to read the json file? require or fs.

  • JSON file is not servedFebruary 11

    In a standard team site, I have a document library that host a static website with html files as well json files loaded asynchronously with javascript. This was working well in SharePoint 2007. unfortunately, since we migrated to SharePoint 2010, a h

  • How to Find Json files in Api url with JsonObject?January 17

    Pleas Expert, i have problem... I have link api some like https://api.myname.com/json/"Files Json" File Json = id 1234.json, 12234.json, 12334.json And in Json file is array : { "id":123456,"name":"Jaka","email

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 1.550 s.