# How to upload ALL encrypted data bags to Chef server?

**URL:** <https://discourse.chef.io/t/how-to-upload-all-encrypted-data-bags-to-chef-server/6530>\
**Category:** Chef Infra (archive)\
**Created:** [April 27, 2015, 7:09pm UTC](https://discourse.chef.io/t/how-to-upload-all-encrypted-data-bags-to-chef-server/6530 "2015-04-27T19:09:01Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_F](https://avatars.discourse-cdn.com/v4/letter/c/fbc32d/32.png) [@Chris\_F](https://discourse.chef.io/u/Chris_F)\
**Post date:** [April 27, 2015, 7:09pm UTC](https://discourse.chef.io/t/how-to-upload-all-encrypted-data-bags-to-chef-server/6530/1 "2015-04-27T19:09:01Z")

</div>

[https://docs.chef.io/knife\_data\_bag.html](https://docs.chef.io/knife_data_bag.html)

I see mention of the -a/–all option here so I tried

$ knife data bag from file -all --secret-file

But I get no command feedback, netiher pass nor fail. Moreover, the NO data bag is uploaded.

Chris

---

<div class="post-metadata">

**Author:** ![Yoshi\_Spendiff](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/yoshi_spendiff/32/13_2.png) [@Yoshi\_Spendiff](https://discourse.chef.io/u/Yoshi_Spendiff)\
**Post date:** [April 27, 2015, 7:29pm UTC](https://discourse.chef.io/t/how-to-upload-all-encrypted-data-bags-to-chef-server/6530/2 "2015-04-27T19:29:27Z")

</div>

Are the files actually different to what exists on the server? I know with  
knife upload it only outputs if it creates or modifies a file. What's the  
exit code of the command?

On Mon, Apr 27, 2015 at 12:09 PM, Fouts, Chris [Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)  
wrote:

> [knife data bag](https://docs.chef.io/knife_data_bag.html)
> 
> I see mention of the -a/--all option here so I tried
> 
> $ knife data bag from file –all --secret-file
> 
> But I get no command feedback, netiher pass nor fail. Moreover, the NO  
> data bag is uploaded.
> 
> Chris

--  
Yoshi Spendiff  
Ops Engineer  
Indochino  
Mobile: +1 778 952 2025  
Email: [yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)

---

<div class="post-metadata">

**Author:** ![Chris\_F](https://avatars.discourse-cdn.com/v4/letter/c/fbc32d/32.png) [@Chris\_F](https://discourse.chef.io/u/Chris_F)\
**Post date:** [April 27, 2015, 7:38pm UTC](https://discourse.chef.io/t/how-to-upload-all-encrypted-data-bags-to-chef-server/6530/3 "2015-04-27T19:38:56Z")

</div>

I’m not using “knife upload” since that command doesn’t seem to have the option to upload encrypted data bags. Rather “knife data bag.” There are NO data bags in the server. Like I said, the command gives NO feedback.

Chris

From: Yoshi Spendiff [[mailto:yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)]  
Sent: Monday, April 27, 2015 3:29 PM  
To: [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
Subject: [chef] Re: How to upload ALL encrypted data bags to Chef server?

Are the files actually different to what exists on the server? I know with knife upload it only outputs if it creates or modifies a file. What’s the exit code of the command?

On Mon, Apr 27, 2015 at 12:09 PM, Fouts, Chris \<[Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)[mailto:Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)\> wrote:  
[https://docs.chef.io/knife\_data\_bag.html](https://docs.chef.io/knife_data_bag.html)

I see mention of the -a/–all option here so I tried

$ knife data bag from file –all --secret-file

But I get no command feedback, netiher pass nor fail. Moreover, the NO data bag is uploaded.

Chris

–  
Yoshi Spendiff  
Ops Engineer  
Indochino  
Mobile: +1 778 952 2025  
Email: [yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)[mailto:yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)

---

<div class="post-metadata">

**Author:** ![Morgan\_Blackthorne](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/morgan_blackthorne/32/100_2.png) [@Morgan\_Blackthorne](https://discourse.chef.io/u/Morgan_Blackthorne)\
**Post date:** [April 27, 2015, 7:51pm UTC](https://discourse.chef.io/t/how-to-upload-all-encrypted-data-bags-to-chef-server/6530/4 "2015-04-27T19:51:36Z")

</div>

Knife upload will upload encrypted data bags. You just need to "knife data  
bag edit somebag someitem --secret-file=somesecret" and then "knife data  
bag show somebag someitem -Fj \> someitem.json" (note, not specifying the  
secret file, otherwise you'll decrypt it). That's how we handle it, at  
least... that way the encrypted bags are still inside git, which is our  
Source of Truth, but only in the encrypted form.

Being able to encrypt the bags without going through "knife data bag edit"  
would be much preferable, however.

--  
~_~ StormeRider ~_~

"Every world needs its heroes [...] They inspire us to be better than we  
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... [http://bit.ly/Ps3uSS](http://bit.ly/Ps3uSS)

On Mon, Apr 27, 2015 at 12:38 PM, Fouts, Chris [Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)  
wrote:

> I’m not using “knife upload” since that command doesn’t seem to have the  
> option to upload encrypted data bags. Rather “knife data bag.” There are NO  
> data bags in the server. Like I said, the command gives NO feedback.
> 
> Chris
> 
> _From:_ Yoshi Spendiff [[mailto:yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)]  
> _Sent:_ Monday, April 27, 2015 3:29 PM  
> _To:_ [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> _Subject:_ [chef] Re: How to upload ALL encrypted data bags to Chef  
> server?
> 
> Are the files actually different to what exists on the server? I know with  
> knife upload it only outputs if it creates or modifies a file. What's the  
> exit code of the command?
> 
> On Mon, Apr 27, 2015 at 12:09 PM, Fouts, Chris [Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)  
> wrote:
> 
> [knife data bag](https://docs.chef.io/knife_data_bag.html)
> 
> I see mention of the -a/--all option here so I tried
> 
> $ knife data bag from file –all --secret-file
> 
> But I get no command feedback, netiher pass nor fail. Moreover, the NO  
> data bag is uploaded.
> 
> Chris
> 
> --
> 
> Yoshi Spendiff
> 
> Ops Engineer
> 
> Indochino
> 
> Mobile: +1 778 952 2025
> 
> Email: [yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)

---

<div class="post-metadata">

**Author:** ![Ranjib](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/ranjib/32/1040_2.png) [@Ranjib](https://discourse.chef.io/u/Ranjib)\
**Post date:** [April 27, 2015, 7:55pm UTC](https://discourse.chef.io/t/how-to-upload-all-encrypted-data-bags-to-chef-server/6530/5 "2015-04-27T19:55:23Z")

</div>

can you try setting the data\_bags\_path in knife config. and omit it from  
the command line?

On Mon, Apr 27, 2015 at 12:09 PM, Fouts, Chris [Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)  
wrote:

> [knife data bag](https://docs.chef.io/knife_data_bag.html)
> 
> I see mention of the -a/--all option here so I tried
> 
> $ knife data bag from file –all --secret-file
> 
> But I get no command feedback, netiher pass nor fail. Moreover, the NO  
> data bag is uploaded.
> 
> Chris

---

<div class="post-metadata">

**Author:** ![Chris\_F](https://avatars.discourse-cdn.com/v4/letter/c/fbc32d/32.png) [@Chris\_F](https://discourse.chef.io/u/Chris_F)\
**Post date:** [April 27, 2015, 7:58pm UTC](https://discourse.chef.io/t/how-to-upload-all-encrypted-data-bags-to-chef-server/6530/6 "2015-04-27T19:58:01Z")

</div>

There are NO data bags in the server YET, so knife data bag edit will NOT work? I’m trying to upload ALL the encrypted data bags for the FIRST time.

Chris

From: Morgan Blackthorne [[mailto:stormerider@gmail.com](mailto:stormerider@gmail.com)]  
Sent: Monday, April 27, 2015 3:52 PM  
To: [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
Subject: [chef] Re: RE: Re: How to upload ALL encrypted data bags to Chef server?

Knife upload will upload encrypted data bags. You just need to “knife data bag edit somebag someitem --secret-file=somesecret” and then “knife data bag show somebag someitem -Fj \> someitem.json” (note, not specifying the secret file, otherwise you’ll decrypt it). That’s how we handle it, at least… that way the encrypted bags are still inside git, which is our Source of Truth, but only in the encrypted form.

Being able to encrypt the bags without going through “knife data bag edit” would be much preferable, however.

–  
~_~ StormeRider ~_~  
“Every world needs its heroes […] They inspire us to be better than we are. And they protect from the darkness that’s just around the corner.”

(from Smallville Season 6x1: “Zod”)

On why I hate the phrase “that’s so lame”… [http://bit.ly/Ps3uSS](http://bit.ly/Ps3uSS)

On Mon, Apr 27, 2015 at 12:38 PM, Fouts, Chris \<[Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)[mailto:Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)\> wrote:  
I’m not using “knife upload” since that command doesn’t seem to have the option to upload encrypted data bags. Rather “knife data bag.” There are NO data bags in the server. Like I said, the command gives NO feedback.

Chris

From: Yoshi Spendiff [[mailto:yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)[mailto:yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)]  
Sent: Monday, April 27, 2015 3:29 PM  
To: [chef@lists.opscode.com](mailto:chef@lists.opscode.com)[mailto:chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
Subject: [chef] Re: How to upload ALL encrypted data bags to Chef server?

Are the files actually different to what exists on the server? I know with knife upload it only outputs if it creates or modifies a file. What’s the exit code of the command?

On Mon, Apr 27, 2015 at 12:09 PM, Fouts, Chris \<[Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)[mailto:Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)\> wrote:  
[https://docs.chef.io/knife\_data\_bag.html](https://docs.chef.io/knife_data_bag.html)

I see mention of the -a/–all option here so I tried

$ knife data bag from file –all --secret-file

But I get no command feedback, netiher pass nor fail. Moreover, the NO data bag is uploaded.

Chris

–  
Yoshi Spendiff  
Ops Engineer  
Indochino  
Mobile: +1 778 952 2025tel:%2B1%20778%20952%202025  
Email: [yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)[mailto:yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)

---

<div class="post-metadata">

**Author:** ![Morgan\_Blackthorne](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/morgan_blackthorne/32/100_2.png) [@Morgan\_Blackthorne](https://discourse.chef.io/u/Morgan_Blackthorne)\
**Post date:** [April 27, 2015, 8:02pm UTC](https://discourse.chef.io/t/how-to-upload-all-encrypted-data-bags-to-chef-server/6530/7 "2015-04-27T20:02:45Z")

</div>

Well, then knife data bag create. Same approach.

--  
~_~ StormeRider ~_~

"Every world needs its heroes [...] They inspire us to be better than we  
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... [http://bit.ly/Ps3uSS](http://bit.ly/Ps3uSS)

On Mon, Apr 27, 2015 at 12:58 PM, Fouts, Chris [Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)  
wrote:

> There are NO data bags in the server YET, so knife data bag edit will  
> NOT work? I’m trying to upload ALL the encrypted data bags for the FIRST  
> time.
> 
> Chris
> 
> _From:_ Morgan Blackthorne [[mailto:stormerider@gmail.com](mailto:stormerider@gmail.com)]  
> _Sent:_ Monday, April 27, 2015 3:52 PM  
> _To:_ [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> _Subject:_ [chef] Re: RE: Re: How to upload ALL encrypted data bags to  
> Chef server?
> 
> Knife upload will upload encrypted data bags. You just need to "knife data  
> bag edit somebag someitem --secret-file=somesecret" and then "knife data  
> bag show somebag someitem -Fj \> someitem.json" (note, not specifying the  
> secret file, otherwise you'll decrypt it). That's how we handle it, at  
> least... that way the encrypted bags are still inside git, which is our  
> Source of Truth, but only in the encrypted form.
> 
> Being able to encrypt the bags without going through "knife data bag edit"  
> would be much preferable, however.
> 
> --
> 
> ~_~ StormeRider ~_~
> 
> "Every world needs its heroes [...] They inspire us to be better than we  
> are. And they protect from the darkness that's just around the corner."
> 
> (from Smallville Season 6x1: "Zod")
> 
> On why I hate the phrase "that's so lame"... [http://bit.ly/Ps3uSS](http://bit.ly/Ps3uSS)
> 
> On Mon, Apr 27, 2015 at 12:38 PM, Fouts, Chris [Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)  
> wrote:
> 
> I’m not using “knife upload” since that command doesn’t seem to have the  
> option to upload encrypted data bags. Rather “knife data bag.” There are NO  
> data bags in the server. Like I said, the command gives NO feedback.
> 
> Chris
> 
> _From:_ Yoshi Spendiff [[mailto:yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)]  
> _Sent:_ Monday, April 27, 2015 3:29 PM  
> _To:_ [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> _Subject:_ [chef] Re: How to upload ALL encrypted data bags to Chef  
> server?
> 
> Are the files actually different to what exists on the server? I know with  
> knife upload it only outputs if it creates or modifies a file. What's the  
> exit code of the command?
> 
> On Mon, Apr 27, 2015 at 12:09 PM, Fouts, Chris [Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)  
> wrote:
> 
> [knife data bag](https://docs.chef.io/knife_data_bag.html)
> 
> I see mention of the -a/--all option here so I tried
> 
> $ knife data bag from file –all --secret-file
> 
> But I get no command feedback, netiher pass nor fail. Moreover, the NO  
> data bag is uploaded.
> 
> Chris
> 
> --
> 
> Yoshi Spendiff
> 
> Ops Engineer
> 
> Indochino
> 
> Mobile: +1 778 952 2025
> 
> Email: [yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)

---

<div class="post-metadata">

**Author:** ![Chris\_F](https://avatars.discourse-cdn.com/v4/letter/c/fbc32d/32.png) [@Chris\_F](https://discourse.chef.io/u/Chris_F)\
**Post date:** [April 27, 2015, 9:31pm UTC](https://discourse.chef.io/t/how-to-upload-all-encrypted-data-bags-to-chef-server/6530/8 "2015-04-27T21:31:22Z")

</div>

Now I’ll have to do a knife data bag create for “EACH” data bag? AVOIDING this was the point of my question. I was trying to figure out a way, if it exists, to NOT do this. The docs seem to suggest there’s a way, but are they misleading and there really isn’t one?

Here’s part of the docs

$ knife data bag from file DATA\_BAG\_NAME\_or\_PATH  
Options  
This argument has the following options:  
-a, --all  
Use to upload all data bags found at the specified path.

Chris

From: Morgan Blackthorne [[mailto:stormerider@gmail.com](mailto:stormerider@gmail.com)]  
Sent: Monday, April 27, 2015 4:03 PM  
To: [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
Subject: [chef] Re: RE: Re: RE: Re: How to upload ALL encrypted data bags to Chef server?

Well, then knife data bag create. Same approach.

–  
~_~ StormeRider ~_~  
“Every world needs its heroes […] They inspire us to be better than we are. And they protect from the darkness that’s just around the corner.”

(from Smallville Season 6x1: “Zod”)

On why I hate the phrase “that’s so lame”… [http://bit.ly/Ps3uSS](http://bit.ly/Ps3uSS)

On Mon, Apr 27, 2015 at 12:58 PM, Fouts, Chris \<[Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)[mailto:Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)\> wrote:  
There are NO data bags in the server YET, so knife data bag edit will NOT work? I’m trying to upload ALL the encrypted data bags for the FIRST time.

Chris

From: Morgan Blackthorne [[mailto:stormerider@gmail.com](mailto:stormerider@gmail.com)[mailto:stormerider@gmail.com](mailto:stormerider@gmail.com)]  
Sent: Monday, April 27, 2015 3:52 PM  
To: [chef@lists.opscode.com](mailto:chef@lists.opscode.com)[mailto:chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
Subject: [chef] Re: RE: Re: How to upload ALL encrypted data bags to Chef server?

Knife upload will upload encrypted data bags. You just need to “knife data bag edit somebag someitem --secret-file=somesecret” and then “knife data bag show somebag someitem -Fj \> someitem.json” (note, not specifying the secret file, otherwise you’ll decrypt it). That’s how we handle it, at least… that way the encrypted bags are still inside git, which is our Source of Truth, but only in the encrypted form.

Being able to encrypt the bags without going through “knife data bag edit” would be much preferable, however.

–  
~_~ StormeRider ~_~  
“Every world needs its heroes […] They inspire us to be better than we are. And they protect from the darkness that’s just around the corner.”

(from Smallville Season 6x1: “Zod”)

On why I hate the phrase “that’s so lame”… [http://bit.ly/Ps3uSS](http://bit.ly/Ps3uSS)

On Mon, Apr 27, 2015 at 12:38 PM, Fouts, Chris \<[Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)[mailto:Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)\> wrote:  
I’m not using “knife upload” since that command doesn’t seem to have the option to upload encrypted data bags. Rather “knife data bag.” There are NO data bags in the server. Like I said, the command gives NO feedback.

Chris

From: Yoshi Spendiff [[mailto:yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)[mailto:yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)]  
Sent: Monday, April 27, 2015 3:29 PM  
To: [chef@lists.opscode.com](mailto:chef@lists.opscode.com)[mailto:chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
Subject: [chef] Re: How to upload ALL encrypted data bags to Chef server?

Are the files actually different to what exists on the server? I know with knife upload it only outputs if it creates or modifies a file. What’s the exit code of the command?

On Mon, Apr 27, 2015 at 12:09 PM, Fouts, Chris \<[Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)[mailto:Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)\> wrote:  
[https://docs.chef.io/knife\_data\_bag.html](https://docs.chef.io/knife_data_bag.html)

I see mention of the -a/–all option here so I tried

$ knife data bag from file –all --secret-file

But I get no command feedback, netiher pass nor fail. Moreover, the NO data bag is uploaded.

Chris

–  
Yoshi Spendiff  
Ops Engineer  
Indochino  
Mobile: +1 778 952 2025tel:%2B1%20778%20952%202025  
Email: [yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)[mailto:yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)

---

<div class="post-metadata">

**Author:** ![Ranjib](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/ranjib/32/1040_2.png) [@Ranjib](https://discourse.chef.io/u/Ranjib)\
**Post date:** [April 27, 2015, 9:38pm UTC](https://discourse.chef.io/t/how-to-upload-all-encrypted-data-bags-to-chef-server/6530/9 "2015-04-27T21:38:17Z")

</div>

can you open a ticket on github, i think this is a neat feature to have, we  
can add a flag to create the databag if absent,

cheers  
ranjib

On Mon, Apr 27, 2015 at 2:31 PM, Fouts, Chris [Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)  
wrote:

> Now I’ll have to do a knife data bag create for “EACH” data bag?  
> AVOIDING this was the point of my question. I was trying to figure out a  
> way, if it exists, to NOT do this. The docs seem to suggest there’s a way,  
> but are they misleading and there really isn’t one?
> 
> Here’s part of the docs
> 
> $ knife data bag from file DATA\_BAG\_NAME\_or\_PATH
> 
> _Options_
> 
> This argument has the following options:
> 
> -a, --all
> 
> Use to upload all data bags found at the specified path.
> 
> Chris
> 
> _From:_ Morgan Blackthorne [[mailto:stormerider@gmail.com](mailto:stormerider@gmail.com)]  
> _Sent:_ Monday, April 27, 2015 4:03 PM  
> _To:_ [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> _Subject:_ [chef] Re: RE: Re: RE: Re: How to upload ALL encrypted data  
> bags to Chef server?
> 
> Well, then knife data bag create. Same approach.
> 
> --
> 
> ~_~ StormeRider ~_~
> 
> "Every world needs its heroes [...] They inspire us to be better than we  
> are. And they protect from the darkness that's just around the corner."
> 
> (from Smallville Season 6x1: "Zod")
> 
> On why I hate the phrase "that's so lame"... [http://bit.ly/Ps3uSS](http://bit.ly/Ps3uSS)
> 
> On Mon, Apr 27, 2015 at 12:58 PM, Fouts, Chris [Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)  
> wrote:
> 
> There are NO data bags in the server YET, so knife data bag edit will NOT  
> work? I’m trying to upload ALL the encrypted data bags for the FIRST time.
> 
> Chris
> 
> _From:_ Morgan Blackthorne [[mailto:stormerider@gmail.com](mailto:stormerider@gmail.com)]  
> _Sent:_ Monday, April 27, 2015 3:52 PM  
> _To:_ [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> _Subject:_ [chef] Re: RE: Re: How to upload ALL encrypted data bags to  
> Chef server?
> 
> Knife upload will upload encrypted data bags. You just need to "knife data  
> bag edit somebag someitem --secret-file=somesecret" and then "knife data  
> bag show somebag someitem -Fj \> someitem.json" (note, not specifying the  
> secret file, otherwise you'll decrypt it). That's how we handle it, at  
> least... that way the encrypted bags are still inside git, which is our  
> Source of Truth, but only in the encrypted form.
> 
> Being able to encrypt the bags without going through "knife data bag edit"  
> would be much preferable, however.
> 
> --
> 
> ~_~ StormeRider ~_~
> 
> "Every world needs its heroes [...] They inspire us to be better than we  
> are. And they protect from the darkness that's just around the corner."
> 
> (from Smallville Season 6x1: "Zod")
> 
> On why I hate the phrase "that's so lame"... [http://bit.ly/Ps3uSS](http://bit.ly/Ps3uSS)
> 
> On Mon, Apr 27, 2015 at 12:38 PM, Fouts, Chris [Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)  
> wrote:
> 
> I’m not using “knife upload” since that command doesn’t seem to have the  
> option to upload encrypted data bags. Rather “knife data bag.” There are NO  
> data bags in the server. Like I said, the command gives NO feedback.
> 
> Chris
> 
> _From:_ Yoshi Spendiff [[mailto:yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)]  
> _Sent:_ Monday, April 27, 2015 3:29 PM  
> _To:_ [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> _Subject:_ [chef] Re: How to upload ALL encrypted data bags to Chef  
> server?
> 
> Are the files actually different to what exists on the server? I know with  
> knife upload it only outputs if it creates or modifies a file. What's the  
> exit code of the command?
> 
> On Mon, Apr 27, 2015 at 12:09 PM, Fouts, Chris [Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)  
> wrote:
> 
> [knife data bag](https://docs.chef.io/knife_data_bag.html)
> 
> I see mention of the -a/--all option here so I tried
> 
> $ knife data bag from file –all --secret-file
> 
> But I get no command feedback, netiher pass nor fail. Moreover, the NO  
> data bag is uploaded.
> 
> Chris
> 
> --
> 
> Yoshi Spendiff
> 
> Ops Engineer
> 
> Indochino
> 
> Mobile: +1 778 952 2025
> 
> Email: [yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)

---

<div class="post-metadata">

**Author:** ![okram999](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/okram999/32/1083_2.png) [@okram999](https://discourse.chef.io/u/okram999)\
**Post date:** [April 27, 2015, 10:23pm UTC](https://discourse.chef.io/t/how-to-upload-all-encrypted-data-bags-to-chef-server/6530/10 "2015-04-27T22:23:43Z")

</div>

I use this all the time

knife data bag from file dev ./data\_bags/dev/dev.json

On Mon, Apr 27, 2015 at 2:38 PM, Ranjib Dey [dey.ranjib@gmail.com](mailto:dey.ranjib@gmail.com) wrote:

> can you open a ticket on github, i think this is a neat feature to have,  
> we can add a flag to create the databag if absent,
> 
> cheers  
> ranjib
> 
> On Mon, Apr 27, 2015 at 2:31 PM, Fouts, Chris [Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)  
> wrote:
> 
> > Now I’ll have to do a knife data bag create for “EACH” data bag?  
> > AVOIDING this was the point of my question. I was trying to figure out a  
> > way, if it exists, to NOT do this. The docs seem to suggest there’s a way,  
> > but are they misleading and there really isn’t one?
> > 
> > Here’s part of the docs
> > 
> > $ knife data bag from file DATA\_BAG\_NAME\_or\_PATH
> > 
> > _Options_
> > 
> > This argument has the following options:
> > 
> > -a, --all
> > 
> > Use to upload all data bags found at the specified path.
> > 
> > Chris
> > 
> > _From:_ Morgan Blackthorne [[mailto:stormerider@gmail.com](mailto:stormerider@gmail.com)]  
> > _Sent:_ Monday, April 27, 2015 4:03 PM  
> > _To:_ [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> > _Subject:_ [chef] Re: RE: Re: RE: Re: How to upload ALL encrypted data  
> > bags to Chef server?
> > 
> > Well, then knife data bag create. Same approach.
> > 
> > --
> > 
> > ~_~ StormeRider ~_~
> > 
> > "Every world needs its heroes [...] They inspire us to be better than we  
> > are. And they protect from the darkness that's just around the corner."
> > 
> > (from Smallville Season 6x1: "Zod")
> > 
> > On why I hate the phrase "that's so lame"... [http://bit.ly/Ps3uSS](http://bit.ly/Ps3uSS)
> > 
> > On Mon, Apr 27, 2015 at 12:58 PM, Fouts, Chris [Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)  
> > wrote:
> > 
> > There are NO data bags in the server YET, so knife data bag edit will NOT  
> > work? I’m trying to upload ALL the encrypted data bags for the FIRST time.
> > 
> > Chris
> > 
> > _From:_ Morgan Blackthorne [[mailto:stormerider@gmail.com](mailto:stormerider@gmail.com)]  
> > _Sent:_ Monday, April 27, 2015 3:52 PM  
> > _To:_ [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> > _Subject:_ [chef] Re: RE: Re: How to upload ALL encrypted data bags to  
> > Chef server?
> > 
> > Knife upload will upload encrypted data bags. You just need to "knife  
> > data bag edit somebag someitem --secret-file=somesecret" and then "knife  
> > data bag show somebag someitem -Fj \> someitem.json" (note, not specifying  
> > the secret file, otherwise you'll decrypt it). That's how we handle it, at  
> > least... that way the encrypted bags are still inside git, which is our  
> > Source of Truth, but only in the encrypted form.
> > 
> > Being able to encrypt the bags without going through "knife data bag  
> > edit" would be much preferable, however.
> > 
> > --
> > 
> > ~_~ StormeRider ~_~
> > 
> > "Every world needs its heroes [...] They inspire us to be better than we  
> > are. And they protect from the darkness that's just around the corner."
> > 
> > (from Smallville Season 6x1: "Zod")
> > 
> > On why I hate the phrase "that's so lame"... [http://bit.ly/Ps3uSS](http://bit.ly/Ps3uSS)
> > 
> > On Mon, Apr 27, 2015 at 12:38 PM, Fouts, Chris [Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)  
> > wrote:
> > 
> > I’m not using “knife upload” since that command doesn’t seem to have the  
> > option to upload encrypted data bags. Rather “knife data bag.” There are NO  
> > data bags in the server. Like I said, the command gives NO feedback.
> > 
> > Chris
> > 
> > _From:_ Yoshi Spendiff [[mailto:yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)]  
> > _Sent:_ Monday, April 27, 2015 3:29 PM  
> > _To:_ [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> > _Subject:_ [chef] Re: How to upload ALL encrypted data bags to Chef  
> > server?
> > 
> > Are the files actually different to what exists on the server? I know  
> > with knife upload it only outputs if it creates or modifies a file. What's  
> > the exit code of the command?
> > 
> > On Mon, Apr 27, 2015 at 12:09 PM, Fouts, Chris [Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)  
> > wrote:
> > 
> > [knife data bag](https://docs.chef.io/knife_data_bag.html)
> > 
> > I see mention of the -a/--all option here so I tried
> > 
> > $ knife data bag from file –all --secret-file
> > 
> > But I get no command feedback, netiher pass nor fail. Moreover, the NO  
> > data bag is uploaded.
> > 
> > Chris
> > 
> > --
> > 
> > Yoshi Spendiff
> > 
> > Ops Engineer
> > 
> > Indochino
> > 
> > Mobile: +1 778 952 2025
> > 
> > Email: [yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)

--  
Regards  
nirish okram

---

<div class="post-metadata">

**Author:** ![Chris\_F](https://avatars.discourse-cdn.com/v4/letter/c/fbc32d/32.png) [@Chris\_F](https://discourse.chef.io/u/Chris_F)\
**Post date:** [April 28, 2015, 2:13am UTC](https://discourse.chef.io/t/how-to-upload-all-encrypted-data-bags-to-chef-server/6530/11 "2015-04-28T02:13:36Z")

</div>

I will open a feature request yes.

It IS my misunderstanding though. This works.

$ knife data bag from file bag\_name –all –secret-file SECRET\_FILE

IOW I thought I could upload all the data bags in the data\_bags dir with above command. However, it only works for upload all the “data bag items” under that data bag.

Chris

From: Ranjib Dey [[mailto:dey.ranjib@gmail.com](mailto:dey.ranjib@gmail.com)]  
Sent: Monday, April 27, 2015 5:38 PM  
To: [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
Subject: [chef] Re: RE: Re: RE: Re: RE: Re: How to upload ALL encrypted data bags to Chef server?

can you open a ticket on github, i think this is a neat feature to have, we can add a flag to create the databag if absent,

cheers  
ranjib

On Mon, Apr 27, 2015 at 2:31 PM, Fouts, Chris \<[Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)[mailto:Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)\> wrote:  
Now I’ll have to do a knife data bag create for “EACH” data bag? AVOIDING this was the point of my question. I was trying to figure out a way, if it exists, to NOT do this. The docs seem to suggest there’s a way, but are they misleading and there really isn’t one?

Here’s part of the docs

$ knife data bag from file DATA\_BAG\_NAME\_or\_PATH  
Options  
This argument has the following options:  
-a, --all  
Use to upload all data bags found at the specified path.

Chris

From: Morgan Blackthorne [[mailto:stormerider@gmail.com](mailto:stormerider@gmail.com)[mailto:stormerider@gmail.com](mailto:stormerider@gmail.com)]  
Sent: Monday, April 27, 2015 4:03 PM  
To: [chef@lists.opscode.com](mailto:chef@lists.opscode.com)[mailto:chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
Subject: [chef] Re: RE: Re: RE: Re: How to upload ALL encrypted data bags to Chef server?

Well, then knife data bag create. Same approach.

–  
~_~ StormeRider ~_~  
“Every world needs its heroes […] They inspire us to be better than we are. And they protect from the darkness that’s just around the corner.”

(from Smallville Season 6x1: “Zod”)

On why I hate the phrase “that’s so lame”… [http://bit.ly/Ps3uSS](http://bit.ly/Ps3uSS)

On Mon, Apr 27, 2015 at 12:58 PM, Fouts, Chris \<[Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)[mailto:Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)\> wrote:  
There are NO data bags in the server YET, so knife data bag edit will NOT work? I’m trying to upload ALL the encrypted data bags for the FIRST time.

Chris

From: Morgan Blackthorne [[mailto:stormerider@gmail.com](mailto:stormerider@gmail.com)[mailto:stormerider@gmail.com](mailto:stormerider@gmail.com)]  
Sent: Monday, April 27, 2015 3:52 PM  
To: [chef@lists.opscode.com](mailto:chef@lists.opscode.com)[mailto:chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
Subject: [chef] Re: RE: Re: How to upload ALL encrypted data bags to Chef server?

Knife upload will upload encrypted data bags. You just need to “knife data bag edit somebag someitem --secret-file=somesecret” and then “knife data bag show somebag someitem -Fj \> someitem.json” (note, not specifying the secret file, otherwise you’ll decrypt it). That’s how we handle it, at least… that way the encrypted bags are still inside git, which is our Source of Truth, but only in the encrypted form.

Being able to encrypt the bags without going through “knife data bag edit” would be much preferable, however.

–  
~_~ StormeRider ~_~  
“Every world needs its heroes […] They inspire us to be better than we are. And they protect from the darkness that’s just around the corner.”

(from Smallville Season 6x1: “Zod”)

On why I hate the phrase “that’s so lame”… [http://bit.ly/Ps3uSS](http://bit.ly/Ps3uSS)

On Mon, Apr 27, 2015 at 12:38 PM, Fouts, Chris \<[Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)[mailto:Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)\> wrote:  
I’m not using “knife upload” since that command doesn’t seem to have the option to upload encrypted data bags. Rather “knife data bag.” There are NO data bags in the server. Like I said, the command gives NO feedback.

Chris

From: Yoshi Spendiff [[mailto:yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)[mailto:yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)]  
Sent: Monday, April 27, 2015 3:29 PM  
To: [chef@lists.opscode.com](mailto:chef@lists.opscode.com)[mailto:chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
Subject: [chef] Re: How to upload ALL encrypted data bags to Chef server?

Are the files actually different to what exists on the server? I know with knife upload it only outputs if it creates or modifies a file. What’s the exit code of the command?

On Mon, Apr 27, 2015 at 12:09 PM, Fouts, Chris \<[Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)[mailto:Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)\> wrote:  
[https://docs.chef.io/knife\_data\_bag.html](https://docs.chef.io/knife_data_bag.html)

I see mention of the -a/–all option here so I tried

$ knife data bag from file –all --secret-file

But I get no command feedback, netiher pass nor fail. Moreover, the NO data bag is uploaded.

Chris

–  
Yoshi Spendiff  
Ops Engineer  
Indochino  
Mobile: +1 778 952 2025tel:%2B1%20778%20952%202025  
Email: [yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)[mailto:yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)

---

<div class="post-metadata">

**Author:** ![Kenneth\_Barry1](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Kenneth\_Barry1](https://discourse.chef.io/u/Kenneth_Barry1)\
**Post date:** [April 28, 2015, 3:44pm UTC](https://discourse.chef.io/t/how-to-upload-all-encrypted-data-bags-to-chef-server/6530/12 "2015-04-28T15:44:19Z")

</div>

I have used for-loops for handling multi-item creation. Not the best  
solution (I would like it to be a feature, to generate bags if not present)

On Mon, Apr 27, 2015 at 7:13 PM, Fouts, Chris [Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)  
wrote:

> I will open a feature request yes.
> 
> It IS my misunderstanding though. This works.
> 
> $ knife data bag from file bag\_name –all –secret-file SECRET\_FILE
> 
> IOW I thought I could upload all the data bags in the data\_bags dir with  
> above command. However, it only works for upload all the “data bag items”  
> under that data bag.
> 
> Chris
> 
> _From:_ Ranjib Dey [[mailto:dey.ranjib@gmail.com](mailto:dey.ranjib@gmail.com)]  
> _Sent:_ Monday, April 27, 2015 5:38 PM  
> _To:_ [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> _Subject:_ [chef] Re: RE: Re: RE: Re: RE: Re: How to upload ALL encrypted  
> data bags to Chef server?
> 
> can you open a ticket on github, i think this is a neat feature to have,  
> we can add a flag to create the databag if absent,
> 
> cheers
> 
> ranjib
> 
> On Mon, Apr 27, 2015 at 2:31 PM, Fouts, Chris [Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)  
> wrote:
> 
> Now I’ll have to do a knife data bag create for “EACH” data bag? AVOIDING  
> this was the point of my question. I was trying to figure out a way, if it  
> exists, to NOT do this. The docs seem to suggest there’s a way, but are  
> they misleading and there really isn’t one?
> 
> Here’s part of the docs
> 
> $ knife data bag from file DATA\_BAG\_NAME\_or\_PATH
> 
> _Options_
> 
> This argument has the following options:
> 
> -a, --all
> 
> Use to upload all data bags found at the specified path.
> 
> Chris
> 
> _From:_ Morgan Blackthorne [[mailto:stormerider@gmail.com](mailto:stormerider@gmail.com)]  
> _Sent:_ Monday, April 27, 2015 4:03 PM  
> _To:_ [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> _Subject:_ [chef] Re: RE: Re: RE: Re: How to upload ALL encrypted data  
> bags to Chef server?
> 
> Well, then knife data bag create. Same approach.
> 
> --
> 
> ~_~ StormeRider ~_~
> 
> "Every world needs its heroes [...] They inspire us to be better than we  
> are. And they protect from the darkness that's just around the corner."
> 
> (from Smallville Season 6x1: "Zod")
> 
> On why I hate the phrase "that's so lame"... [http://bit.ly/Ps3uSS](http://bit.ly/Ps3uSS)
> 
> On Mon, Apr 27, 2015 at 12:58 PM, Fouts, Chris [Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)  
> wrote:
> 
> There are NO data bags in the server YET, so knife data bag edit will NOT  
> work? I’m trying to upload ALL the encrypted data bags for the FIRST time.
> 
> Chris
> 
> _From:_ Morgan Blackthorne [[mailto:stormerider@gmail.com](mailto:stormerider@gmail.com)]  
> _Sent:_ Monday, April 27, 2015 3:52 PM  
> _To:_ [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> _Subject:_ [chef] Re: RE: Re: How to upload ALL encrypted data bags to  
> Chef server?
> 
> Knife upload will upload encrypted data bags. You just need to "knife data  
> bag edit somebag someitem --secret-file=somesecret" and then "knife data  
> bag show somebag someitem -Fj \> someitem.json" (note, not specifying the  
> secret file, otherwise you'll decrypt it). That's how we handle it, at  
> least... that way the encrypted bags are still inside git, which is our  
> Source of Truth, but only in the encrypted form.
> 
> Being able to encrypt the bags without going through "knife data bag edit"  
> would be much preferable, however.
> 
> --
> 
> ~_~ StormeRider ~_~
> 
> "Every world needs its heroes [...] They inspire us to be better than we  
> are. And they protect from the darkness that's just around the corner."
> 
> (from Smallville Season 6x1: "Zod")
> 
> On why I hate the phrase "that's so lame"... [http://bit.ly/Ps3uSS](http://bit.ly/Ps3uSS)
> 
> On Mon, Apr 27, 2015 at 12:38 PM, Fouts, Chris [Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)  
> wrote:
> 
> I’m not using “knife upload” since that command doesn’t seem to have the  
> option to upload encrypted data bags. Rather “knife data bag.” There are NO  
> data bags in the server. Like I said, the command gives NO feedback.
> 
> Chris
> 
> _From:_ Yoshi Spendiff [[mailto:yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)]  
> _Sent:_ Monday, April 27, 2015 3:29 PM  
> _To:_ [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> _Subject:_ [chef] Re: How to upload ALL encrypted data bags to Chef  
> server?
> 
> Are the files actually different to what exists on the server? I know with  
> knife upload it only outputs if it creates or modifies a file. What's the  
> exit code of the command?
> 
> On Mon, Apr 27, 2015 at 12:09 PM, Fouts, Chris [Chris.Fouts@sensus.com](mailto:Chris.Fouts@sensus.com)  
> wrote:
> 
> [knife data bag](https://docs.chef.io/knife_data_bag.html)
> 
> I see mention of the -a/--all option here so I tried
> 
> $ knife data bag from file –all --secret-file
> 
> But I get no command feedback, netiher pass nor fail. Moreover, the NO  
> data bag is uploaded.
> 
> Chris
> 
> --
> 
> Yoshi Spendiff
> 
> Ops Engineer
> 
> Indochino
> 
> Mobile: +1 778 952 2025
> 
> Email: [yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)

--

Kenneth Barry  
TuneIn | Build and Release Engineer  
M: 409-673-0544

> **[TuneIn | Free Internet Radio | Live News, Sports, Music, Audiobooks, and...](https://tunein.com/)**
>
> Listen to free internet radio, news, sports, music, audiobooks, and podcasts. Stream live CNN, FOX News Radio, and MSNBC. Plus 100,000 AM/FM radio stations featuring music, news, and local sports talk.
