Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chef-zero not copying data_bags into cache #83

Closed
AnalogJ opened this issue Aug 2, 2014 · 3 comments
Closed

chef-zero not copying data_bags into cache #83

AnalogJ opened this issue Aug 2, 2014 · 3 comments

Comments

@AnalogJ
Copy link

AnalogJ commented Aug 2, 2014

This looks pretty similar to #56 , except my files are named correctly.

I have the following folder structure

$ cd var/chef/cookbooks/zero && find .

./metadata.rb
./README.md
./attributes
./CHANGELOG.md
./data_bags
./data_bags/zero
./data_bags/zero/fluff.json
./recipes
./recipes/default.rb

And my default recipe looks like:

$ cat recipes/default.rb

a = search(:node, "*:*")
b = data_bag_item("zero", "fluff")

file "/tmp/zerofiles" do
  content a[0].to_s
end

file "/tmp/fluff" do
  content b.to_s
end

But when I run chef-client -z -o zero I get the following error:

[2014-08-01T22:11:35-04:00] WARN: No config file found or specified on command line, using command line options.
Starting Chef Client, version 11.14.0.rc.2
[2014-08-01T22:11:36-04:00] WARN: Run List override has been provided.
[2014-08-01T22:11:36-04:00] WARN: Original Run List: []
[2014-08-01T22:11:36-04:00] WARN: Overridden Run List: [recipe[zero]]
resolving cookbooks for run list: ["zero"]
Synchronizing Cookbooks:
  - zero
Compiling Cookbooks...
[2014-08-01T22:11:36-04:00] ERROR: Failed to load data bag item: "zero" "fluff"

================================================================================
Recipe Compile Error in /home/user/.chef/local-mode-cache/cache/cookbooks/zero/recipes/default.rb
================================================================================

Net::HTTPServerException
------------------------
404 "Not Found "

Cookbook Trace:
---------------
  /home/user/.chef/local-mode-cache/cache/cookbooks/zero/recipes/default.rb:2:in `from_file'

Relevant File Content:
----------------------
/home/user/.chef/local-mode-cache/cache/cookbooks/zero/recipes/default.rb:

  1:  a = search(:node, "*:*")
  2>> b = data_bag_item("zero", "fluff")
  3:  
  4:  file "/tmp/zerofiles" do
  5:    content a[0].to_s
  6:  end
  7:  
  8:  file "/tmp/fluff" do
  9:    content b.to_s
 10:  end
 11:  


Running handlers:
[2014-08-01T22:11:36-04:00] ERROR: Running exception handlers
Running handlers complete
[2014-08-01T22:11:36-04:00] ERROR: Exception handlers complete
[2014-08-01T22:11:36-04:00] FATAL: Stacktrace dumped to /home/user/.chef/local-mode-cache/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 1.607884477 seconds
[2014-08-01T22:11:36-04:00] ERROR: 404 "Not Found "
[2014-08-01T22:11:36-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

I took a look at my chef-zero cache, and as a matter of fact, the data_bags folder was not copied over.

$ cd /home/user/.chef/local-mode-cache/cache/cookbooks/zero && find . 

./metadata.rb
./README.md
./CHANGELOG.md
./recipes
./recipes/default.rb

Am I missing something? Is there additional configuration required to tell chef-zero to copy over the data-bags?

$ chef-client --version 
Chef: 11.14.0.rc.2
@sethvargo
Copy link
Contributor

@AnalogJ what are the permissions on those folders/files?

@AnalogJ
Copy link
Author

AnalogJ commented Aug 2, 2014

Everything is owned by user:user, both in the /var/chef/cookbooks/zero folder and the cache that chef-zero creates

@AnalogJ
Copy link
Author

AnalogJ commented Sep 13, 2014

ok I figured this out a while ago, but forgot to update the issue.. the databags need to be brought up to the chef-zero root level
Here's what my working folder structure looks like

.cookbooks/zero/metadata.rb
.cookbooks/zero/README.md
.cookbooks/zero/attributes
.cookbooks/zero/CHANGELOG.md
.cookbooks/zero/data_bags
.cookbooks/zero/data_bags/zero
.cookbooks/zero/data_bags/zero/fluff.json
.cookbooks/zero/recipes
.cookbooks/zero/recipes/default.rb
.data_bags/zero
.data_bags/zero/fluff.json

Basically as part of my script that extracts my cookbooks into the /var/chef/cookbooks folder, I copy the necessary databags into a data_bags folder thats a sibling the cookbooks folder.
Everything works as normal after that.

@AnalogJ AnalogJ closed this as completed Sep 13, 2014
@chef chef locked and limited conversation to collaborators Nov 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants