未找到Chef remote_directory cookbook @recipe_files

时间:2017-08-08 10:47:13

标签: ruby chef

我创建了一个简单的方法,可以在Windows上将文件从一个目录复制到另一个目录。

配方:

remote_directory 'C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\destination' do
  source 'C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\source'
  action :create
end

但是,在尝试在--local-mode中执行配方时,为了在将配方部署到Chef服务器上之前测试配方,我收到以下错误:

PS C:\chef-repo\chef-repo\cookbooks\chef-repo> chef-client
--local-mode .\copyBinaries.rb [2017-08-08T13:34:03+03:00] INFO: Started chef-zero at chefzero://localhost:1 with repository at C:/chef-repo/chef-repo   One version per cookbook

Starting Chef Client, version 13.2.20 [2017-08-08T13:34:03+03:00] INFO: *** Chef 13.2.20 *** [2017-08-08T13:34:03+03:00] INFO: Platform: i386-mingw32 [2017-08-08T13:34:03+03:00] INFO: Chef-client pid: 10708 [2017-08-08T13:34:03+03:00] INFO: The plugin path C:\chef\ohai\plugins does not exist. Skipping... [2017-08-08T13:34:12+03:00] INFO: Run List is [] [2017-08-08T13:34:12+03:00] INFO: Run List expands to [] [2017-08-08T13:34:12+03:00] INFO: Starting Chef Run for mohammedr [2017-08-08T13:34:12+03:00] INFO: Running start handlers [2017-08-08T13:34:12+03:00] INFO: Start handlers complete. resolving cookbooks for run list: [] [2017-08-08T13:34:12+03:00] INFO: Loading cookbooks [] Synchronizing Cookbooks: Installing Cookbook Gems: Compiling Cookbooks... [2017-08-08T13:34:12+03:00] WARN: Node mohammedr has an empty run list. Converging 1 resources Recipe: @recipe_files::C:/chef-repo/chef-repo/cookbooks/chef-repo/copyBinaries.rb
* remote_directory[C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\destination] action create[2017-08-08T13:34:12+03:00] INFO: Processing remote_directory[C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\destination] action create (@recipe_files::C:/chef-repo/chef-repo/cookbooks/chef-repo/copyBinaries.rb line 7)


    ================================================================================
    Error executing action `create` on resource 'remote_directory[C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\destination]'
    ================================================================================

    Chef::Exceptions::CookbookNotFound
    ----------------------------------
    Cookbook @recipe_files not found. If you're loading @recipe_files from another cookbook, make sure you configure the dependency in your metadata

    Resource Declaration:
    ---------------------
    # In C:/chef-repo/chef-repo/cookbooks/chef-repo/copyBinaries.rb

      7: remote_directory 'C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\destination' do
      8:   source 'C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\source'
      9:   action :create
     10: end
     11:

    Compiled Resource:
    ------------------
    # Declared in C:/chef-repo/chef-repo/cookbooks/chef-repo/copyBinaries.rb:7:in `from_file'

    remote_directory("C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\destination") do
      action [:create]
      default_guard_interpreter :default
      path "C:\\chef-repo\\chef-repo\\cookbooks\\chef-repo\\recipes\\destination"
      recursive true
      source "C:\\chef-repo\\chef-repo\\cookbooks\\chef-repo\\recipes\\source"
      files_backup 5
      files_owner nil
      files_group nil
      overwrite true
      declared_type :remote_directory
      cookbook_name "@recipe_files"
      recipe_name "C:/chef-repo/chef-repo/cookbooks/chef-repo/copyBinaries.rb"
      mode nil
      owner nil
      group nil
      files_mode nil
    end

    System Info:
    ------------
    chef_version=13.2.20
    platform=windows
    platform_version=10.0.14393
    ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [i386-mingw32]
    program_name=C:/opscode/chefdk/modules/chef/../../bin/chef-client
    executable=C:/opscode/chefdk/bin/chef-client

[2017-08-08T13:34:12+03:00] INFO: Running queued delayed notifications before re-raising exception

Running handlers: [2017-08-08T13:34:12+03:00] ERROR: Running exception handlers Running handlers complete [2017-08-08T13:34:12+03:00] ERROR: Exception handlers complete Chef Client failed. 0 resources updated in 09 seconds [2017-08-08T13:34:12+03:00] FATAL: Stacktrace dumped to c:/chef-repo/chef-repo/.chef/local-mode-cache/cache/chef-stacktrace.out [2017-08-08T13:34:12+03:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report [2017-08-08T13:34:12+03:00] FATAL: Chef::Exceptions::CookbookNotFound: remote_directory[C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\destination] (@recipe_files::C:/chef-repo/chef-repo/cookbooks/chef-repo/copyBinaries.rb line 7) had an error: Chef::Exceptions::CookbookNotFound: Cookbook @recipe_files not found. If you're loading @recipe_files from another cookbook, make sure you configure the dependency in your metadata

我已尝试在互联网上搜索有关此问题的解决方案,但我找不到任何有用的内容。

1 个答案:

答案 0 :(得分:1)

remote_directory资源从cookbook的files/文件夹中获取文件。

你做的事对我来说看起来很奇怪 - 你正在复制食谱,你正在硬编码到食谱的本地路径。更好地问一个新问题,包括你的实际目标。我非常有信心remote_directory不是你想要的。