【问题标题】:How to set http_proxy for chef remote_file resource如何为厨师 remote_file 资源设置 http_proxy
【发布时间】:2020-06-29 21:21:57
【问题描述】:

我正在寻求帮助,我需要从 https url 从 chef-cookbook 下载二进制文件,但我无法从客户端服务器直接调用该 url。

我可以使用 curl 下载它,但是在使用端口传递代理服务器之后。 但我想使用 remote_file 资源,我无法为我的 https url 设置代理,因为远程文件中没有选项。

谁能帮帮我。

提前致谢

【问题讨论】:

    标签: chef-infra cookbook


    【解决方案1】:

    您需要设置proxy setting in chef-client configuration

    http_proxy HTTP 连接的代理服务器。默认值:nil

    http_proxy_pass 代理服务器使用 HTTP 连接时的代理服务器密码。默认值:nil

    http_proxy_user 代理服务器使用 HTTP 连接时代理服务器的用户名。默认值:nil

    您可能想利用chef-client cookbook 来设置这些设置

    【讨论】:

    • 您好,感谢您的回答。我已经手动尝试过了,到目前为止它工作正常。但是当我尝试通过说明书本身设置它之前,然后使用 remote_file 资源下载文件时它不起作用。但是当我再次运行相同的食谱时,它的工作文件。你能帮忙解决什么问题吗?下面的代码我用来通过说明书设置代理: ruby​​_block "set https_proxy" do block do file = Chef::Util::FileEdit.new("/etc/chef/client.rb" ) file.insert_line_if_no_match("https_proxy","https_proxy 'example.com:20080'") file.write_file end end
    • 如果它对你有用,那么请接受我的回答。其次,请创建一个包含所有错误和详细信息的新问题,我很乐意为您提供帮助
    【解决方案2】:

    ruby_block '设置 https_proxy' 做 阻止做 ENV['https_proxy'] = "https://:20080" 结尾 结束

    以上代码帮助我设置了 https_proxy。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多