【问题标题】:403 forbidden error while running chef scripts运行厨师脚本时出现 403 禁止错误
【发布时间】:2016-08-05 15:06:52
【问题描述】:

我正在目标节点上从厨师服务器运行厨师引导命令。脚本对于初始配方运行良好,但随着它的进展,我们看到 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)

【问题讨论】:

  • 您使用的是什么版本的 Chef?
  • 您的跑步需要很长时间吗?我认为 11.14 大约是我们默认启用延迟加载模板文件的时间,因此 URL 签名可能会在很长一段时间内过期。您可以通过在 client.rb 中将 no_lazy_load 设置为 true 来解决此问题。
  • 你能告诉我在哪里添加 no_lazy_load 吗?它是在厨师客户端还是厨师服务器?我没有 client.rb 的配方。

标签: chef-infra chef-recipe


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    根据Chef Docs中的建议,这个错误可以通过其他方式解决。

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

    opscode_erchef['s3_url_ttl'] = 3600
    

    Chef Docs 描述如下,

    opscode_erchef['s3_url_ttl']

    连接到服务器之前的时间量(以秒为单位) 到期。如果 chef-client 运行超时,请将此设置增加到 3600,必要时再调整。默认值:900。

    这个解决方案很有用,以防在不久的将来无法切换到新版本的 Chef。

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-04
      • 2015-08-19
      • 1970-01-01
      • 1970-01-01
      • 2012-09-26
      • 1970-01-01
      • 1970-01-01
      • 2015-12-01
      相关资源
      最近更新 更多