Назад | Перейти на главную страницу

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 не httpd_deploy/templates/index.html.erb