我正在努力在厨师部署一本食谱。 但是,它找不到要查找的目录中的文件。
我的食谱安装并启动Apache,然后应该用我生成的简单模板replace默认的index.html,但是它不能在食谱中find我修改的index.html.erb,所以不要replace它。
这里是我的环境:
打印版本,这可能是有用的:
[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
我正在启动食谱作为本地testing:
[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
正如错误消息所述,您需要将模板放置在templates/index.html.erb而不是httpd_deploy/templates/index.html.erb