Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
828adbf7
Commit
828adbf7
authored
Dec 16, 2014
by
Toshio Kuratomi
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9807 from swimlappy/noproxy
Request: Honor the "no_proxy" environment variable in Ansible
parents
d1e27fe8
38dbce15
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
lib/ansible/module_utils/urls.py
+24
-0
No files found.
lib/ansible/module_utils/urls.py
View file @
828adbf7
...
@@ -252,9 +252,33 @@ class SSLValidationHandler(urllib2.BaseHandler):
...
@@ -252,9 +252,33 @@ class SSLValidationHandler(urllib2.BaseHandler):
except
:
except
:
self
.
module
.
fail_json
(
msg
=
'Connection to proxy failed'
)
self
.
module
.
fail_json
(
msg
=
'Connection to proxy failed'
)
def
detect_no_proxy
(
self
,
url
):
'''
Detect if the 'no_proxy' environment variable is set and honor those locations.
'''
env_no_proxy
=
os
.
environ
.
get
(
'no_proxy'
)
if
env_no_proxy
:
env_no_proxy
=
env_no_proxy
.
split
(
','
)
netloc
=
urlparse
.
urlparse
(
url
)
.
netloc
for
host
in
env_no_proxy
:
if
netloc
.
endswith
(
host
)
or
netloc
.
split
(
':'
)[
0
]
.
endswith
(
host
):
# Our requested URL matches something in no_proxy, so don't
# use the proxy for this
return
False
return
True
def
http_request
(
self
,
req
):
def
http_request
(
self
,
req
):
tmp_ca_cert_path
,
paths_checked
=
self
.
get_ca_certs
()
tmp_ca_cert_path
,
paths_checked
=
self
.
get_ca_certs
()
https_proxy
=
os
.
environ
.
get
(
'https_proxy'
)
https_proxy
=
os
.
environ
.
get
(
'https_proxy'
)
# Detect if 'no_proxy' environment variable is set and if our URL is included
use_proxy
=
self
.
detect_no_proxy
(
req
.
get_full_url
())
if
not
use_proxy
:
# ignore proxy settings for this host request
return
req
try
:
try
:
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
if
https_proxy
:
if
https_proxy
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment