我正在为在厨师中部署食谱而苦苦挣扎。但是,它没有找到它正在寻找的目录中存在的文件。
我的食谱安装并启动 Apache,然后应该用我生成的简单模板替换默认 index.html,但它在食谱中找不到我修改过的 index.html.erb,所以不要替换它。
这是我的环境:
印刷版,可能有用:
[root@centos-bpo1 cookbooks]# chef --version
Chef Development Kit Version: 2.3.4
chef-client version: 13.4.19
delivery version: master (73ebb72a6c42b3d2ff5370c476be800fee7e5427)
berks version: 6.3.1
kitchen version: 1.17.0
inspec version: 1.36.1
打印我的食谱“httpd_deploy”的内容:
[root@centos-bpo1 cookbooks]# cd httpd_deploy/
[root@centos-bpo1 httpd_deploy]# tree
.
├── Berksfile
├── chefignore
├── httpd_deploy
│ └── templates
│ └── index.html.erb
├── LICENSE
├── metadata.rb
├── README.md
├── recipes
│ └── default.rb
├── spec
│ ├── spec_helper.rb
│ └── unit
│ └── recipes
│ └── default_spec.rb
└── test
└── smoke
└── default
└── default_test.rb
打印配方“httpd_deploy”的内容:
[root@centos-bpo1 httpd_deploy]# cat recipes/default.rb
#
# Cookbook:: httpd_deploy
# Recipe:: default
#
# Copyright:: 2017, The Authors, All Rights Reserved.
package 'httpd'
service 'httpd' do
action [:enable, :start]
end
template '/var/www/html/index.html' do
source 'index.html.erb'
end
打印源文件“index.html.erb”的内容:
[root@centos-bpo1 httpd_deploy]# cat httpd_deploy/templates/index.html.erb
Welcome to Chef Apache Deployment
我将这本食谱作为本地测试推出:
[root@centos-bpo1 httpd_deploy]# cd ..
[root@centos-bpo1 cookbooks]# chef-client --local-mode --runlist 'recipe[httpd_deploy]'
以下是结果(截断):
[2017-10-02T10:58:22+02:00] ERROR: template[/var/www/html/index.html] (httpd_deploy::default line 10) had an error: Chef::Exceptions::FileNotFound: Cookbook 'httpd_deploy' (0.1.0) does not contain a file at any of these locations:
templates/centos-7.4.1708/index.html.erb
templates/centos/index.html.erb
templates/default/index.html.erb
templates/index.html.erb