I have written a basic cookbook to configure the proxy server on a machine (Windows) and I can’t seem to get it to write the variable as a ‘SYSTEM’ variable - It always shows up as a user variable. Second that, it only seems to write the first variable as well?
The client/node is Windows 10
Here is the code:
proxy = 'http://proxy.bravurasolutions.local:3128' # Proxy server URL
no_proxy = 'localhost,127.0.0.1,sv.local'
proxy_bypass = 'localhost;127.0.0.1;*.sv.local'
# HTTP_PROXY environment variable
env 'HTTP_PROXY' do
value "#{proxy}"
not_if { ::ENV.key?('HTTP_PROXY') == true or ::ENV.empty?('HTTP_PROXY') == false }
end
# HTTPS_PROXY environment variable
env 'HTTPS_PROXY' do
value "#{proxy}"
not_if { ::ENV.key?('HTTPS_PROXY') == true or ::ENV.empty?('HTTPS_PROXY') == true }
end
# Proxy exceptions list
env 'NO_PROXY' do
value "#{no_proxy}"
not_if { ::ENV.key?('HTTP_PROXY') == true or ::ENV.empty?('NO_PROXY') == true }
end
# This is to satisfy the 'Internet options - Proxy & proxy bypass' settings'
powershell_script 'set_internet_options' do
<<-EOH
netsh winhttp set proxy "#{proxy}" bypass-list="#{proxy_bypass}"
EOH
end