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

chef-client local mode not able to create action on template resource on windows machine

我正在本地模式下执行厨师食谱食谱,我已将模板 .erb 文件放在食谱模板文件夹下。 它给出错误和 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

我的厨师回购树: C:。 ├────.主厨 │ └────本地模式缓存 │ └────缓存 │ └────食谱 │ └────测试 │ ├────属性 │ ├────食谱 │ └────模板 | |___test-template.txt.erb ├────食谱 │ └────my_cookbook │ ├────属性 │ ├────定义 │ ├────文件 │ │ └──默认 │ ├────图书馆 │ ├────供应商 │ ├────食谱 │ ├────资源 │ └────模板 │ └────默认 | |___test-template.txt.erb<br> ├────data_bags │ └────范例 ├────环境 ├────节点 └────角色

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

模板资源在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 属性。

  • 您在玩包装食谱时在模板名称或位置的某处输入错误。