Knife data bag from file with --all

I am trying to get the --all option to work:

knife data bag from file [bag_name] --all # all data bag items assuming that
data bags are in the ./data_bags/

Although I successfully used create to first define a data bag on the server
and I can use from file with a data bag and an item .json file to upload a
single item, I cannot figure out how to use the --all option to upload all
items for a specified data bag. When I run it, a blank line is returned and
nothing is uploaded.

Does anyone have a working example of the --all option?

On a related topic, what is the difference inusing knife upload to upload data
bags or other content as compared to using the knife from file options?

Doesn’t “knife data bag from file [bag_name] *.json” work?

Thanks,
Matt Ray
Senior Technical Evangelist :: Opscode
512.731.2218 :: matt@opscode.com
mattray :: GitHub :: IRC :: Twitter


From: cpkampmeier@gmail.com [cpkampmeier@gmail.com]
Sent: Tuesday, March 26, 2013 9:46 PM
To: chef@lists.opscode.com
Subject: [chef] knife data bag from file with --all

I am trying to get the --all option to work:

knife data bag from file [bag_name] --all # all data bag items assuming that
data bags are in the ./data_bags/

Although I successfully used create to first define a data bag on the server
and I can use from file with a data bag and an item .json file to upload a
single item, I cannot figure out how to use the --all option to upload all
items for a specified data bag. When I run it, a blank line is returned and
nothing is uploaded.

Does anyone have a working example of the --all option?

On a related topic, what is the difference inusing knife upload to upload data
bags or other content as compared to using the knife from file options?

Yes, using *.json works. Thanks for the tip.

I suppose I'll need to dig into the --all support in the source to get a
better feel for whether it is supposed to work before filing a bug.

Chris

On 3/27/13 8:52 AM, Matt Ray wrote:

Doesn't "knife data bag from file [bag_name] *.json" work?

Thanks,
Matt Ray
Senior Technical Evangelist :: Opscode
512.731.2218 :: matt@opscode.com
mattray :: GitHub :: IRC :: Twitter


From: cpkampmeier@gmail.com [cpkampmeier@gmail.com]
Sent: Tuesday, March 26, 2013 9:46 PM
To: chef@lists.opscode.com
Subject: [chef] knife data bag from file with --all

I am trying to get the --all option to work:

knife data bag from file [bag_name] --all # all data bag items assuming that
data bags are in the ./data_bags/

Although I successfully used create to first define a data bag on the server
and I can use from file with a data bag and an item .json file to upload a
single item, I cannot figure out how to use the --all option to upload all
items for a specified data bag. When I run it, a blank line is returned and
nothing is uploaded.

Does anyone have a working example of the --all option?

On a related topic, what is the difference inusing knife upload to upload data
bags or other content as compared to using the knife from file options?

FWIW, I wrote a simple thor job to do this. Th guts of it look something
like this:

Chef::Config.from_file( < path to knife.rb >)
Dir.glob('./data_bags/*').select{|d| File.directory? d}.each do
|data_bag_dir|
bag = File.basename data_bag_dir
begin
Chef::DataBag.load(bag)
rescue Net::HTTPServerException => e
raise e unless e.response.code == "404"
dbag = Chef::DataBag.new
dbag.name(bag)
dbag.save
end

from_file = Chef::knife::DataBagFromFile.new
from_file.name_args = [ bag, data_bag_dir]
from_file.run
end

On Thu, Mar 28, 2013 at 8:44 PM, Christopher Kampmeier <
cpkampmeier@gmail.com> wrote:

Yes, using *.json works. Thanks for the tip.

I suppose I'll need to dig into the --all support in the source to get a
better feel for whether it is supposed to work before filing a bug.

Chris

On 3/27/13 8:52 AM, Matt Ray wrote:

Doesn't "knife data bag from file [bag_name] *.json" work?

Thanks,
Matt Ray
Senior Technical Evangelist :: Opscode
512.731.2218 :: matt@opscode.com
mattray :: GitHub :: IRC :: Twitter

____________________**
From: cpkampmeier@gmail.com [cpkampmeier@gmail.com]
Sent: Tuesday, March 26, 2013 9:46 PM
To: chef@lists.opscode.com
Subject: [chef] knife data bag from file with --all

I am trying to get the --all option to work:

knife data bag from file [bag_name] --all # all data bag items assuming
that
data bags are in the ./data_bags/

Although I successfully used create to first define a data bag on the
server
and I can use from file with a data bag and an item .json file to upload a
single item, I cannot figure out how to use the --all option to upload all
items for a specified data bag. When I run it, a blank line is returned
and
nothing is uploaded.

Does anyone have a working example of the --all option?

On a related topic, what is the difference inusing knife upload to upload
data
bags or other content as compared to using the knife from file options?