2017-08-08 185 views
0

我創建了一個簡單的配方,在Windows上將文件從一個目錄複製到另一個目錄。廚師remote_directory食譜@recipe_files沒有找到

方藥:

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模式的配方用於測試的配方的緣故,當出現以下錯誤廚師服務器上部署它之前:

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

remote_directory資源獲取食譜的files/文件夾中的文件。

你對我做什麼看起來很奇怪 - 你正在複製食譜,而且你正在對食譜的本地路徑進行硬編碼。最好問一個新問題,包括你的實際目標。我非常有信心,remote_directory是不是你想要的。

+0

我的目標是將二進制文件從一個目錄複製到另一個目錄,比如釋放服務器到由Chef Server管理的節點,或同一節點上的兩個目錄之間。注意:我爲了測試而編寫硬編碼路徑。 –

+0

什麼,從遠程服務器或本地?這是一個區別(在廚師實施中)。只要發佈服務器通過HTTP提供服務,就可以使用'remote_file'資源。 – StephenKing

+0

目前我們所有的服務器都可以在我們的局域網中使用。有些情況下,我們想要在同一臺服務器中複製二進制文件,有時在同一局域網中的兩臺不同服務器之間複製。沒有任何東西正在複製到雲端。 –