Chef
廚師無法找到食譜中存在的文件 - Chef::Exceptions::FileNotFound
我正在為在廚師中部署食譜而苦苦掙扎。但是,它沒有找到它正在尋找的目錄中存在的文件。
我的食譜安裝並啟動 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
正如錯誤消息所說,您需要將模板放在
templates/index.html.erb
nothttpd_deploy/templates/index.html.erb