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
38dbce15
Commit
38dbce15
authored
Dec 13, 2014
by
Jason Holland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow Ansible to honor the "no_proxy" environment varaible.
parent
12968acd
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 @
38dbce15
...
...
@@ -252,9 +252,33 @@ class SSLValidationHandler(urllib2.BaseHandler):
except
:
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
):
tmp_ca_cert_path
,
paths_checked
=
self
.
get_ca_certs
()
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
:
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
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