是的 - 这个过程记录在这个要点中,但简而言之:
在您的.kitchen.yml
:
<%
require 'socket'
def local_ip
@local_ip ||= begin
# turn off reverse DNS resolution temporarily
orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true
UDPSocket.open do |s|
s.connect '64.233.187.99', 1
s.addr.last
end
ensure
Socket.do_not_reverse_lookup = orig
end
end
def local_port ; 8123 ; end
def http_proxy_url ; "http://#{local_ip}:#{local_port}" ; end
def proxy_running?
socket = TCPSocket.new(local_ip, local_port)
true
rescue SocketError, Errno::ECONNREFUSED,
Errno::EHOSTUNREACH, Errno::ENETUNREACH, IOError
false
rescue Errno::EPERM, Errno::ETIMEDOUT
false
ensure
socket && socket.close
end
%>
---
<% if proxy_running? %>
driver:
http_proxy: <%= http_proxy_url %>
https_proxy: <%= http_proxy_url %>
provision_command: "env http_proxy=<%= http_proxy_url %> bash -c 'curl -L http://www.getchef.com/chef/install.sh | bash'"
provisioner:
chef_omnibus_url: http://www.getchef.com/chef/install.sh
<% end %>
运行代理的说明使用 polipo,但您可以使用任何您想要的缓存代理。