Apache chef通过包装器cookbook编辑现有配置

Apache chef通过包装器cookbook编辑现有配置,apache,chef-infra,cookbook,Apache,Chef Infra,Cookbook,我有两本包装食谱和一本社区食谱apache2。第一本包装器食谱是我们的core\u dispatcher包装器,它使用apache2广泛用于所有客户机。第二个包装器用于特定的客户机client\u dispatchercookbook。我只想对一个客户端进行更改,因此我使用了第二个客户端调度器包装器来包装核心调度器包装器 这是我要添加到client\u dispatcherwrapper的行 ErrorDocument 404 /content/en/error/404.html 我在我的cl

我有两本包装食谱和一本社区食谱
apache2
。第一本包装器食谱是我们的
core\u dispatcher
包装器,它使用
apache2
广泛用于所有客户机。第二个包装器用于特定的客户机
client\u dispatcher
cookbook。我只想对一个客户端进行更改,因此我使用了第二个
客户端调度器
包装器来包装
核心调度器
包装器

这是我要添加到
client\u dispatcher
wrapper的行

ErrorDocument 404 /content/en/error/404.html
我在我的
client\u dispatcher
中创建了一个新模板
anon\u errordoc.erb
,然后在erb文件中硬编码
ErrorDocument 404/content/en/error/404.html
。我希望将其添加到服务器上已经存在的现有vhost
anoncom.conf

在我的客户包装配方中,我有以下内容:

include_recipe 'core_dispatcher::default'

edit_resource(:template, '/etc/httpd/sites-available/anoncom.conf') do
  source 'anon-errordoc.erb'
  cookbook 'client_dispatcher'
end
运行chef客户端后出错

Recipe: <Dynamically Defined Resource>
* template[/etc/httpd/sites-available/anoncom.conf] action create

================================================================================
Error executing action `create` on resource 'template[/etc/httpd/sites-available/anoncom.conf]'
================================================================================

Chef::Exceptions::FileNotFound
------------------------------
Cookbook 'client_dispatcher' (0.1.13) does not contain a file at any of these locations:
  templates/amazon-2017.09/dispatcher-vhost.conf.erb
  templates/amazon/dispatcher-vhost.conf.erb
  templates/default/dispatcher-vhost.conf.erb
  templates/dispatcher-vhost.conf.erb

This cookbook _does_ contain: ['/var/chef/cache/cookbooks/client_dispatcher/templates/default/filters-anon.conf.erb','/var/chef/cache/cookbooks/client_dispatcher/templates/default/anoncom-errordoc.erb']

Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/apache2/definitions/web_app.rb

 28:   template "#{node['apache']['dir']}/sites-available/#{application_name}.conf" do
 29:     source params[:template]
 30:     local params[:local]
 31:     owner 'root'
 32:     group node['apache']['root_group']
 33:     mode '0644'
 34:     cookbook params[:cookbook] if params[:cookbook]
 35:     variables(
 36:       :application_name => application_name,
 37:       :params           => params
 38:     )
 39:     if ::File.exist?("#{node['apache']['dir']}/sites-enabled/#{application_name}.conf")
 40:       notifies :reload, 'service[apache2]', :delayed
 41:     end
 42:   end

Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/apache2/definitions/web_app.rb:28:in `block in from_file'

  template("/etc/httpd/sites-available/anoncom.conf") do
  params {:template=>"dispatcher-vhost.conf.erb", :local=>false, :enable=>true, :server_port=>"80", :server_name=>"dev-anoncom.ctmsp.com", :server_aliases=>["dev-anoncom.ctmsp.com"], :docroot=>"/var/www/cache/publish/anoncom", :name=>"anoncom"}
  action [:create]
  retries 0
  retry_delay 2
  default_guard_interpreter :default
  source "dispatcher-vhost.conf.erb"
  cookbook "client_dispatcher"
  variables {:application_name=>"anoncom", :params=>{:template=>"dispatcher-vhost.conf.erb", :local=>false, :enable=>true, :server_port=>"80", :server_name=>"dev-anoncom.ctmsp.com", :server_aliases=>["dev-anoncom.ctmsp.com"], :docroot=>"/var/www/cache/publish/anoncom", :name=>"anoncom"}}
  declared_type :template
  cookbook_name "core_dispatcher"
  mode "0644"
  owner "root"
  group "root"
  path "/etc/httpd/sites-available/anoncom.conf"
  verifications []
end

Platform:
---------
x86_64-linux


Running handlers:
Running handlers complete
配方:
*模板[/etc/httpd/sites available/anoncom.conf]操作创建
================================================================================
执行操作“创建资源”模板[/etc/httpd/sites available/anoncom.conf]时出错
================================================================================
Chef::异常::FileNotFound
------------------------------
Cookbook“client_dispatcher”(0.1.13)在以下任何位置均不包含文件:
templates/amazon-2017.09/dispatcher-vhost.conf.erb
templates/amazon/dispatcher-vhost.conf.erb
templates/default/dispatcher-vhost.conf.erb
模板/dispatcher-vhost.conf.erb
本食谱包含:['/var/chef/cache/cookbooks/client\u dispatcher/templates/default/filters-anon.conf.erb','/var/chef/cache/cookbooks/client\u dispatcher/templates/default/anoncom errordoc.erb']
资源声明:
---------------------
#在/var/chef/cache/cookbooks/apache2/definitions/web_app.rb中
28:模板“#{node['apache']['dir']}/sites available/#{application_name}.conf”do
29:源参数[:模板]
30:本地参数[:本地]
31:所有者“根”
32:组节点['apache']['root_group']
33:模式“0644”
34:cookbook参数[:cookbook]如果参数[:cookbook]
35:变量(
36::应用程序名称=>应用程序名称,
37::params=>params
38:     )
39:if::File.exist?(“#{node['apache']['dir']}/sites enabled/#{application_name}.conf”)
40:通知:重新加载“服务[apache2],:延迟
41:完
42:完
汇编资源:
------------------
#在/var/chef/cache/cookbooks/apache2/definitions/web_app.rb:28:in“block in from_file”中声明
模板(“/etc/httpd/sites available/anoncom.conf”)是否
参数{:template=>“dispatcher vhost.conf.erb”,:local=>false,:enable=>true,:server\u port=>“80”,:server\u name=>“dev anoncom.ctmsp.com”,:server\u alias=>[“dev anoncom.ctmsp.com”],:docroot=>“/var/www/cache/publish/anoncom”,:name=>“anoncom”}
动作[:创建]
重试0次
重试\u延迟2
默认\u保护\u解释器:默认值
来源“dispatcher vhost.conf.erb”
食谱“客户机\调度程序”
变量{:application\u name=>“anoncom”,:params=>{:template=>“dispatcher vhost.conf.erb”,:local=>false,:enable=>true,:server\u port=>“80”,:server\u name=>“dev anoncom.ctmsp.com”,:server\u别名=>[“dev anoncom.ctmsp.com”],:docroot=>“/var/www/cache/publish/anoncom”,:name=>“anoncom”}
声明的类型:模板
食谱名称“核心调度员”
模式“0644”
所有者“根”
组“根”
路径“/etc/httpd/sites available/anoncom.conf”
核实[]
结束
站台:
---------
x86_64-linux
正在运行的处理程序:
正在运行的处理程序已完成

这是什么版本的厨师?考虑到输出,我猜有些东西很老了?我运行的是chef版本12.19.36