运行 Chef 脚本时禁止出现 403 错误



我正在目标节点上运行 chef 服务器引导命令。脚本对于初始配方运行良好,但随着它的进展,我们看到 403 被禁止并退出。仅当尝试从模板文件夹复制文件时,才会发生此 403。当我执行另一个食谱时,我也看到了同样的问题。

配方没有问题,因为相同的说明书在不同的目标节点上运行时没有问题。

有人知道如何解决这个问题吗?

Error executing action `create` on resource 'template[/tmp/rsp_files/WebGate_Installation_response_file.rsp]'
     ================================================================================
     Net::HTTPServerException
     ------------------------
     403 "Forbidden"
     Resource Declaration:
     ---------------------
     # In /var/chef/cache/cookbooks/ohs/recipes/install_webgate.rb
      59: template "#{node['OHS']['RSP_FILE']}/WebGate_Installation_response_file.rsp" do
      60:   source 'WebGate_Installation_response_file.rsp.erb'
      61:   owner node['OHS']['USER']
      62:   group node['OHS']['GROUP']
      63:   mode '0644'
      64:   not_if do ::File.exists?("#{node['OHS']['RSP_FILE']}/WebGate_Installation_response_file.rsp") end
      65: end
      66:
     Compiled Resource:
     ------------------
     # Declared in /var/chef/cache/cookbooks/ohs/recipes/install_webgate.rb:59:in `from_file'
     template("/tmp/rsp_files/WebGate_Installation_response_file.rsp") do
       provider Chef::Provider::Template
       action "create"
       retries 0
       retry_delay 2
       guard_interpreter :default
       path "/tmp/rsp_files/WebGate_Installation_response_file.rsp"
       backup 5
       atomic_update true
       source "WebGate_Installation_response_file.rsp.erb"
       cookbook_name "ohs"
       recipe_name "install_webgate"
       owner "oracle"
       group "oinstall"
       mode "0644"
       not_if { #code block }
     end

 Running handlers:
 [2016-05-31T17:21:45-04:00] ERROR: Running exception handlers
 Running handlers complete
 [2016-05-31T17:21:45-04:00] ERROR: Exception handlers complete
 [2016-05-31T17:21:45-04:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
 Chef Client failed. 23 resources updated in 929.166495413 seconds
 [2016-05-31T17:21:45-04:00] ERROR: template[/tmp/rsp_files/WebGate_Installation_response_file.rsp] (ohs::install_webgate line 59) had an error: Net::HTTPServerException: 403 "Forbidden"
 [2016-05-31T17:21:45-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

no_lazy_load true添加到/etc/chef/client.rb 。或者升级到更新的 Chef 版本,我们通过将该配置选项设置为默认值来解决此问题。

根据 Chef 文档中的建议,可以通过其他方式解决此错误。

尝试添加下面提到的 Chef 服务器配置值(在 chef-server.rb 或 private-chef.rb 文件中)

opscode_erchef['s3_url_ttl'] = 3600

厨师文档描述如下:

opscode_erchef[s3_url_ttl]

连接到服务器之前的时间量(以秒为单位) 到期。如果主客户端运行超时,请将此设置增加到 3600,然后根据需要再次调整。默认值:900。

如果在不久的将来无法切换到较新版本的 Chef,此解决方案可能很有用。

如果由于服务器量较大而难以添加 client.rb 选项。

注意:在配置文件中添加该选项需要在 Chef 服务器中执行重新配置。

相关内容

最新更新