【问题标题】:Chef::Exceptions::FileNotFound: template[/var/www/html/index.html]Chef::Exceptions::FileNotFound: 模板[/var/www/html/index.html]
【发布时间】:2020-04-25 21:44:24
【问题描述】:

我是厨师的新手,我不明白什么是问题。以下是我的默认脚本

apt_update 'Update the apt cache daily' do
  frequency 86_400
  action :periodic
end

package 'apache2'

service 'apache2' do
  supports status: true
  action [:enable, :start]
end

template '/var/www/html/index.html' do
  source 'index.html.erb'
end

这是我遇到的错误

[2020-04-25T12:57:00+00:00] FATAL: Stacktrace dumped to /home/vagrant/.chef/local-mode-cache/cache/chef-stacktrace.out
[2020-04-25T12:57:00+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2020-04-25T12:57:00+00:00] FATAL: Chef::Exceptions::FileNotFound: template[/var/www/html/index.html] (learn_chef_apache2::default line 18) had an error: Chef::Exceptions::FileNotFound: Cookbook 'learn_chef_apache2' (0.1.0) does not contain a file at any of these locations:
  templates/host-vagrant.vm/index.html.erb
  templates/ubuntu-18.04/index.html.erb
  templates/ubuntu/index.html.erb
  templates/default/index.html.erb
  templates/index.html.erb

这是我的食谱树

cookbooks
├── learn_chef_apache2
│   ├── Berksfile
│   ├── CHANGELOG.md
│   ├── chefignore
│   ├── LICENSE
│   ├── metadata.rb
│   ├── README.md
│   ├── recipes
│   │   └── default.rb
│   ├── spec
│   │   ├── spec_helper.rb
│   │   └── unit
│   │       └── recipes
│   │           └── default_spec.rb
│   └── test
│       └── integration
│           └── default
│               └── default_test.rb
├── learn_chef_appache2
│   └── templates
│       ├── default
│       └── index.html.erb
└── templates
    └── index.html.erb

有人可以帮助我我做错了什么,如果你能分享一个链接或解释它以供我理解,那就太好了。

【问题讨论】:

    标签: templates chef-infra cookbook


    【解决方案1】:

    我做错的是我的模板是在 learn_chef_apache2 外部创建的,而它应该在内部如下所示

    cookbooks
    └── learn_chef_apache2
        ├── Berksfile
        ├── CHANGELOG.md
        ├── chefignore
        ├── index.html.erb
        ├── LICENSE
        ├── metadata.rb
        ├── README.md
        ├── recipes
        │   └── default.rb
        ├── spec
        │   ├── spec_helper.rb
        │   └── unit
        │       └── recipes
        │           └── default_spec.rb
        ├── templates
        │   └── index.html.erb
        └── test
            └── integration
                └── default
                    └── default_test.rb
    

    【讨论】:

      猜你喜欢
      • 2020-07-04
      • 2017-01-08
      • 2015-09-26
      • 1970-01-01
      • 2015-05-30
      • 1970-01-01
      • 2021-12-20
      • 2015-08-05
      • 1970-01-01
      相关资源
      最近更新 更多