0
當我們嘗試在虛擬機中創建文件時,我們正面臨http 403的禁止。我們使用下面的廚師代碼來完成這項工作。http 403禁止部署
X_FILES = %w{x-log4j.properties x-override.properties x-core.properties x.conf}
x_FILES.each do |file|
template "/etc/b2b/x/#{file}" do
mode 0644
source "#{file}.erb"
owner 'root'
action :create
notifies :restart, "service[a2a-x]"
only_if { File.exist?("/etc/a2a/x") }
helpers MongoUtil
helpers xUtil
end
end
我們有多個虛擬機,錯誤不一致。重新啓動部署作業時,進程正常。
錯誤日誌如下
[2015-10-01T01:40:03+05:30] INFO: Processing template[/etc/b2b/x/x-log4j.properties] action create (b2b::install_configure_x line 89)
[2015-10-01T01:40:04+05:30] INFO: HTTP Request Returned 403 Forbidden:
================================================================================
Error executing action `create` on resource 'template[/etc/b2b/x/x-log4j.properties]'
================================================================================
Net::HTTPServerException
------------------------
403 "Forbidden"
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/b2b/recipes/install_configure_x.rb
89: template "/etc/b2b/x/#{file}" do
90: mode 0644
91: source "#{file}.erb"
92: owner 'root'
93: action :create
94: notifies :restart, "service[b2b-x]"
95: only_if { File.exist?("/etc/b2b/x") }
96: helpers MongoUtil
97: helpers TenantIdUtil
98: end
99: end
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/b2b/recipes/install_configure_x.rb:89:in `block in from_file'
template("/etc/b2b/x/x-log4j.properties") do
provider Chef::Provider::Template
action [:create]
retries 0
retry_delay 2
guard_interpreter :default
path "/etc/b2b/x/x-log4j.properties"
backup 5
atomic_update true
source "x-log4j.properties.erb"
helper_modules [MongoUtil, TenantIdUtil]
cookbook_name "b2b"
recipe_name "install_configure_x"
mode 420
owner "root"
only_if { #code block }
end
在這方面的任何幫助是極大的讚賞。提前致謝。
403在哪裏出現?任何日誌輸出? – StephenKing
事實上,如果你可以提供錯誤的完整堆棧跟蹤和一些日誌片段,我們可以告訴你更多。當我看到像'助手MongoUtil'和'helper xUtil'這樣的東西時,基本上'任何代碼都可以在這裏,我們不會知道它'。 – Martin
嗨,感謝您的回覆。編輯並添加日誌 – ayniam