【问题标题】:chef-client local mode not able to create action on template resource on windows machinechef-client 本地模式无法在 Windows 机器上的模板资源上创建操作
【发布时间】:2017-03-08 13:31:29
【问题描述】:

我正在本地模式下执行厨师食谱食谱,我已将模板 .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

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

【问题讨论】:

  • 我已经添加了食谱内容以及树。

标签: windows chef-infra chef-recipe chef-solo


【解决方案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 属性。

  • 在玩包装食谱时,您在模板名称或位置的某处有错字。

【讨论】:

  • 感谢检查 metadata.rb,那里的名称属性有误。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-28
相关资源
最近更新 更多