From e31ec12fac3d89ed051faa66964ae17c994683c3 Mon Sep 17 00:00:00 2001 From: egon010 Date: Wed, 6 Mar 2013 17:47:01 -0800 Subject: [PATCH 1/3] Add pip environment for proxy settings Add pip environment for http_proxy,https_proxy,no_proxy if set in client.rb --- providers/pip.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/providers/pip.rb b/providers/pip.rb index 862f8d4..cbf8b77 100644 --- a/providers/pip.rb +++ b/providers/pip.rb @@ -151,7 +151,8 @@ def remove_package(version) def pip_cmd(subcommand, version='') options = { :timeout => new_resource.timeout, :user => new_resource.user, :group => new_resource.group } - options[:environment] = { 'HOME' => ::File.expand_path("~#{new_resource.user}") } if new_resource.user + options[:environment] = { 'http_proxy' => Chef::Config[:http_proxy], 'https_proxy' => Chef::Config[:https_proxy], 'no_proxy' => Chef::Config[:no_proxy] } + options[:environment]['HOME'] = ::File.expand_path("~#{@new_resource.user}") if @new_resource.user shell_out!("#{which_pip(new_resource)} #{subcommand} #{new_resource.options} #{new_resource.name}#{version}", options) end From b885e7fa1670e56f93b4543269bb4124366e6600 Mon Sep 17 00:00:00 2001 From: James Downs Date: Thu, 7 Mar 2013 08:34:08 -0800 Subject: [PATCH 2/3] Change to inherit ENV for pip shell_out, and add http proxy settings from client.rb if they're not in the environment already --- providers/pip.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/providers/pip.rb b/providers/pip.rb index cbf8b77..823f55a 100644 --- a/providers/pip.rb +++ b/providers/pip.rb @@ -151,7 +151,8 @@ def remove_package(version) def pip_cmd(subcommand, version='') options = { :timeout => new_resource.timeout, :user => new_resource.user, :group => new_resource.group } - options[:environment] = { 'http_proxy' => Chef::Config[:http_proxy], 'https_proxy' => Chef::Config[:https_proxy], 'no_proxy' => Chef::Config[:no_proxy] } + options[:environment] = ENV.to_hash + options[:environment].merge!('http_proxy' => ENV['http_proxy'] || Chef::Config[:http_proxy], 'https_proxy' => ENV['https_proxy'] || Chef::Config[:https_proxy], 'no_proxy' => ENV['no_proxy'] || Chef::Config[:no_proxy]) options[:environment]['HOME'] = ::File.expand_path("~#{@new_resource.user}") if @new_resource.user shell_out!("#{which_pip(new_resource)} #{subcommand} #{new_resource.options} #{new_resource.name}#{version}", options) end From a14f30e2e8a75ee98c20cb518e7af70d6f980031 Mon Sep 17 00:00:00 2001 From: James Downs Date: Thu, 7 Mar 2013 14:06:50 -0800 Subject: [PATCH 3/3] Use ENV.fetch to prevent breakage for use with solo --- providers/pip.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/providers/pip.rb b/providers/pip.rb index 823f55a..3bb91e4 100644 --- a/providers/pip.rb +++ b/providers/pip.rb @@ -151,8 +151,11 @@ def remove_package(version) def pip_cmd(subcommand, version='') options = { :timeout => new_resource.timeout, :user => new_resource.user, :group => new_resource.group } - options[:environment] = ENV.to_hash - options[:environment].merge!('http_proxy' => ENV['http_proxy'] || Chef::Config[:http_proxy], 'https_proxy' => ENV['https_proxy'] || Chef::Config[:https_proxy], 'no_proxy' => ENV['no_proxy'] || Chef::Config[:no_proxy]) + options[:environment] = { + 'http_proxy' => ENV.fetch('http_proxy', Chef::Config[:http_proxy]), + 'https_proxy' => ENV.fetch('https_proxy', Chef::Config[:https_proxy]), + 'no_proxy' => ENV.fetch('no_proxy', Chef::Config[:no_proxy]), + } options[:environment]['HOME'] = ::File.expand_path("~#{@new_resource.user}") if @new_resource.user shell_out!("#{which_pip(new_resource)} #{subcommand} #{new_resource.options} #{new_resource.name}#{version}", options) end