chef-provisioning icon indicating copy to clipboard operation
chef-provisioning copied to clipboard

Cookbook @recipe_files not found fatal while runing with chef 12.3

Open szymonpk opened this issue 9 years ago • 38 comments

I'm running simple provisioning

require 'chef/provisioning/fog_driver/driver'

with_chef_server 'https://api.opscode.com/organizations/someorg',
                 client_name: Chef::Config[:node_name],
                 signing_key_filename: Chef::Config[:client_key]

machine 'web1' do
  recipe 'web_server'
  converge true
end

via CHEF_PROFILE=shellyinten chef-client -c ~/.chef/knife.rb provision.rb. Server is booting up properly, chef is running, but the end I'm getting fatal error:

[2015-05-01T17:04:28+02:00] FATAL: Stacktrace dumped to /Users/szymon/.chef/cache/chef-stacktrace.out
Chef Client failed. 1 resources updated in 57.613821 seconds
[2015-05-01T17:04:28+02:00] ERROR: Cookbook @recipe_files not found. If you're loading @recipe_files from another cookbook, make sure you configure the dependency in your metadata
[2015-05-01T17:04:28+02:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

szymonpk avatar May 01 '15 15:05 szymonpk

Yes I am also facing the same issue with AWS as provider.
For reference , using Chef Client, version 12.3.0

# it is windows.rb
require 'chef/provisioning/aws_driver'

with_driver 'aws::us-east-1'

with_machine_options({
  bootstrap_options: {
    image_id: "ami-f70cdd9c", # default for us-west-1
    instance_type: "t2.small"
  },
  convergence_options: {
    # The following are only available for Windows machines
    install_msi_url: "https://opscode-omnibus-packages.s3.amazonaws.com/windows/2008r2/x86_64/chef-client-12.4.1-1.msi"
  },
  aws_tags: { :key1 => "value", "key2" => "value"},
  is_windows: true # set to true if using a Windows AMI
})

machine 'my-windows-web-7' do
  run_list ['hello-world'] 
end

The command used for is

chef-client.bat -c D:\project\source\chef-repo\.chef\client.rb .\windows.rb

Any solution for this ?

Regards, -Vinayak

vinayakbhadage avatar Aug 20 '15 06:08 vinayakbhadage

+1

chrisduong avatar Aug 26 '15 08:08 chrisduong

In matter of fact I don't have such issue anymore. I'm not sure how it was solved. Where do you store cookbooks? In same directory from you are running chef-client?

szymonpk avatar Aug 26 '15 08:08 szymonpk

No, I'm provisioning with Chef Server. all my cookbooks are in Chef Server

chrisduong avatar Aug 26 '15 09:08 chrisduong

And how does your client.rb look like?

szymonpk avatar Aug 27 '15 06:08 szymonpk

log_location             STDOUT
node_name                "my-provisioner"
client_key               "/etc/chef/my-provisioner.pem"
chef_server_url          'https://chef-srv02.ireland.internal/organizations/my'
trusted_certs_dir        '/etc/chef/trusted_certs'

chrisduong avatar Aug 27 '15 07:08 chrisduong

I've added cookbook_path to mine (I'm always running from chef repo directory so paths are relative)

cookbook_path ['./cookbooks', './site-cookbooks']

Check it please.

szymonpk avatar Aug 27 '15 07:08 szymonpk

I added as you suggested, it is still the same error. I pointed to my Chef Repo cookbooks.

chrisduong avatar Aug 27 '15 07:08 chrisduong

Ok I see what helped :/ downgrade to 12.2.x

szymonpk avatar Aug 27 '15 07:08 szymonpk

kk, thanks. But I stay with 12.4.1. It is still minor. Hope they would fix soon

chrisduong avatar Aug 27 '15 08:08 chrisduong

I think the best solution is to use ChefDK, these warnings may be caused by some mixup of chef-provisioning and chef gems versions.

szymonpk avatar Aug 27 '15 08:08 szymonpk

I'm actually using ChefDK 0.7.0 for my provisioner.

chrisduong avatar Aug 27 '15 09:08 chrisduong

@chrisduong Can you grab a full stacktrace from a failing run and put it in a gist?

tyler-ball avatar Sep 03 '15 17:09 tyler-ball

Hi @tyler-ball, here is the gist

chrisduong avatar Sep 04 '15 04:09 chrisduong

Okay, it looks like the recipe name is set by https://github.com/chef/chef/blob/1ef5f566480ba84091a12f2b6c5e85f44af54a5b/lib/chef/run_context.rb#L306-L315

I know there were some issues with Chef 12.3.0 - would you mind using 12.4.1 or the latest ChefDK and see if this is still an issue?

tyler-ball avatar Sep 09 '15 20:09 tyler-ball

I'm using the latest one.

$ chef --version
Chef Development Kit Version: 0.7.0
chef-client version: 12.4.1
berks version: 3.2.4

chrisduong avatar Sep 10 '15 04:09 chrisduong

I don't think this has anything to do with provisioning except that users are far more likely to run into this using chef-client -z my_provisioning_recipe.rb. But Its still a bug and I would like to investigate to create a repro (hopefully one without provisioning).

tyler-ball avatar Sep 10 '15 13:09 tyler-ball

Hi,

I've just found out. No matter what I set in client.rb for cookbook_path, when provisioning, the return aws_object always come with the same cookbook_path to "/home/abc/.chef/cache/cookbook"

aws_object("some-name") do
  action [:create]
  retries 0
  retry_delay 2
  default_guard_interpreter :default
  driver #<Chef::Provisioning::AWSDriver::Driver:0x00000008e62708 @driver_url="aws::eu-west-1",@config={:log_location=>#<IO:<STDOUT>>, :node_name=>"my-provisioner", :client_key=>"/home/abc/my/repo/chef-repo/.chef/my-provisioner.pem", :chef_server_url=>"https://chef-srv02.ireland.my.internal/organizations/my", 
:cookbook_path=>**"/home/abcd/.chef/cache/cookbooks"**, 
:trusted_certs_dir=>"/home/abcd/my/repo/chef-repo/.chef/trusted_certs", :force_logger=>false, :force_formatter=>false, :color=>true, :named_run_list=>nil, :config_file=>".chef/client.rb", :log_level=>:info, :specific_recipes=>["/home/abcd/Dropbox/my/repo/chef-repo/cookbooks/s_aws_resources/test/scripts/aws_security_group/dest_is_all_port.rb"], :formatters=>[], :event_handlers=>[], :authentication_protocol_version=>"1.0", :start_handlers=>[], :chef_provisioning=>{}},

chrisduong avatar Dec 10 '15 07:12 chrisduong

Any workaround on this issue? It blocks production deployment process

ghost avatar Dec 11 '15 17:12 ghost

+1

nascimento avatar Jan 14 '16 21:01 nascimento

Hi,

I've just kinda sorted it out, at least for my case. It meant that chef-client cannot found the recipe even though it still execute the the ruby file(provision.rb) as the last argument.

IMHO, Chef client means to run with recipe by looking in cookbook_path, not to execute a ruby file - chef-apply is for doing that job. So the proper way is to pass a recipe, not a ruby file. For e.g.

chef-client -o 'recipe[abd::provisioning_sth]'

Your job is to make sure that you set the correct cookbook_path so chef-client can find it.

chrisduong avatar Jan 15 '16 08:01 chrisduong

It worked fine with previous chef iterations, there were no deprecation warnings between versions. It it was unintended feature it should be restored ;-)

szymonpk avatar Jan 15 '16 09:01 szymonpk

bump

What @szymonpk said. This should either work as previously or be explicitly documented.

pdehlke avatar Feb 28 '16 16:02 pdehlke

Same issue here

rainkinz avatar Feb 29 '16 16:02 rainkinz

I don't see this issue on 12.6.0 anymore.

szymonpk avatar Mar 02 '16 09:03 szymonpk

I still see the issue in 12.7.2.

ramereth avatar Mar 09 '16 17:03 ramereth

Aha! I see what's still not working. If you give chef-client two ruby files, it still breaks but if you give it one file it works again. Easy workaround for me at least.

ramereth avatar Mar 09 '16 17:03 ramereth

I'm seeing this issue on v12.9.38. We also use multiple files that we pass to chef-client with desired order. Packing everything to one file make it work but it's breaking our current workflow. :/

stuszynski avatar Apr 15 '16 13:04 stuszynski

I think I recreated this issue too whilst trying to provision a vagrant host - https://gist.github.com/equick/915010979aefc2f80aef9260a28d8fa1 . It seems to be caused by the two files provided as @ramereth mentioned above although in my case I need both.

equick avatar Apr 24 '16 20:04 equick

I'm not sure chef-client -z was ever supposed to accept multiple recipes to run. You could make a single recipe that includes the others, either using include_recipe, Kernel.load or instance_eval. I'm not sure which will work off the top of my head

tyler-ball avatar May 03 '16 16:05 tyler-ball