我有两本包装食谱和一本社区食谱apache2
。第一个包装器cookbook是我们的core_dispatcher
包装器,它使用apache2
广泛用于所有客户端。第二个包装器用于特定客户端client_dispatcher
食谱。我想只对一个客户端进行更改,因此我使用包装client_dispatcher
包装器的第二个core_dispatcher
包装器。
这是我要添加到client_dispatcher
包装器
ErrorDocument 404 /content/en/error/404.html
我在anon_errordoc.erb
中创建了一个新模板client_dispatcher
,并在erb文件中对其进行了硬编码ErrorDocument 404 /content/en/error/404.html
。我希望将其添加到我服务器上已存在的现有vhost anoncom.conf
中。
在我的client_wrapper配方中,我有以下内容:
include_recipe 'core_dispatcher::default'
edit_resource(:template, '/etc/httpd/sites-available/anoncom.conf') do
source 'anon-errordoc.erb'
cookbook 'client_dispatcher'
end
运行chef-client
后出错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