chef-client本地模式无法在Windows机器上的模板资源上创建操作

时间:2017-03-08 13:31:30

标签: windows chef chef-recipe chef-solo

我正在本地模式下执行厨师食谱配方,我已将模板.erb文件放在cookbooks模板文件夹下。 它给出了错误和Chef :: Exceptions :: CookbookNotFound

附加执行日志

PS C:\chef-repo> chef-client -z -r "recipe[my_cookbook::test1]"
Starting Chef Client, version 12.18.31
resolving cookbooks for run list: ["my_cookbook::test1"]
Synchronizing Cookbooks:
  - test (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 1 resources
Recipe: test::test1
  * template[c:\test-template.txt] action create

    ================================================================================
    Error executing action `create` on resource 'template[c:\test-template.txt]'
    ================================================================================

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

    Resource Declaration:
    ---------------------
    # In c:/chef-repo/.chef/local-mode-cache/cache/cookbooks/test/recipes/test1.rb

      1: template "c:\\test-template.txt" do
      2:   source "test-template.txt.erb"
      3:   mode '0755'
      4:   variables({
      5:     test: node['cloud']['public_ipv4']
      6:   })
      7: end

    Compiled Resource:
    ------------------
    # Declared in c:/chef-repo/.chef/local-mode-cache/cache/cookbooks/test/recipes/test1.rb:1:in `from_file'

    template("c:\test-template.txt") do
      action [:create]
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      source "test-template.txt.erb"
      variables {:test=>"1.1.1.1"}
      declared_type :template
      cookbook_name "test"
      recipe_name "test1"
      mode "0755"
      path "c:\\test-template.txt"
    end

    Platform:
    ---------
    x64-mingw32


Running handlers:
[2017-03-08T12:32:35+00:00] ERROR: Running exception handlers
Running handlers complete
[2017-03-08T12:32:35+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 05 seconds
[2017-03-08T12:32:35+00:00] FATAL: Stacktrace dumped to c:/chef-repo/.chef/local-mode-cache/cache/chef-stacktrace.out
[2017-03-08T12:32:35+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-03-08T12:32:35+00:00] FATAL: Chef::Exceptions::CookbookNotFound: template[c:\test-template.txt] (test::test1 line
1) had an error: Chef::Exceptions::CookbookNotFound: Cookbook test not found. If you're loading test from another cookbo
ok, make sure you configure the dependency in your metadata
test1.rb

template "c:\\test-template.txt" do
 source "test-template.txt.erb"
 mode '0755'
 variables({
   test: node['cloud']['public_ipv4']
 })
end

My chef-repo tree : C:. ├───.chef │ └───local-mode-cache │ └───cache │ └───cookbooks │ └───test │ ├───attributes │ ├───recipes │ └───templates | |___test-template.txt.erb ├───cookbooks │ └───my_cookbook │ ├───attributes │ ├───definitions │ ├───files │ │ └───default │ ├───libraries │ ├───providers │ ├───recipes │ ├───resources │ └───templates │ └───default | |___test-template.txt.erb
├───data_bags │ └───example ├───environments ├───nodes └───roles

1 个答案:

答案 0 :(得分:1)

只是一个猜测,但我认为这是错误的:

模板资源在c:/chef-repo/.chef/local-mode-cache/cache/cookbooks/test/templates/test-template.txt.erb中查找源文件。

使用这些日志行:

resolving cookbooks for run list: ["my_cookbook::test1"]
...
Converging 1 resources
Recipe: test::test1

这让我想到了:

  • 您的实际食谱模板位于" c:/chef-repo/.chef/local-mode-cache/cache/cookbooks/my_cookbook/templates/test-template.txt.erb"和您的metadata.rb使用错误的name属性。

  • 在玩包装食谱时,您在模板名称或位置的某处出现了拼写错误。