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
a90bb89b
Commit
a90bb89b
authored
Apr 09, 2015
by
Brian Coca
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10664 from cchurch/winrm_fixes
WinRM Connection Fixes
parents
c75baaa1
7ba2950c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
15 deletions
+8
-15
lib/ansible/runner/connection_plugins/winrm.py
+7
-14
lib/ansible/runner/shell_plugins/powershell.py
+1
-1
No files found.
lib/ansible/runner/connection_plugins/winrm.py
View file @
a90bb89b
...
@@ -18,8 +18,6 @@
...
@@ -18,8 +18,6 @@
from
__future__
import
absolute_import
from
__future__
import
absolute_import
import
base64
import
base64
import
hashlib
import
imp
import
os
import
os
import
re
import
re
import
shlex
import
shlex
...
@@ -44,10 +42,6 @@ try:
...
@@ -44,10 +42,6 @@ try:
except
ImportError
:
except
ImportError
:
pass
pass
_winrm_cache
=
{
# 'user:pwhash@host:port': <protocol instance>
}
def
vvvvv
(
msg
,
host
=
None
):
def
vvvvv
(
msg
,
host
=
None
):
verbose
(
msg
,
host
=
host
,
caplevel
=
4
)
verbose
(
msg
,
host
=
host
,
caplevel
=
4
)
...
@@ -84,22 +78,22 @@ class Connection(object):
...
@@ -84,22 +78,22 @@ class Connection(object):
vvv
(
"ESTABLISH WINRM CONNECTION FOR USER:
%
s on PORT
%
s TO
%
s"
%
\
vvv
(
"ESTABLISH WINRM CONNECTION FOR USER:
%
s on PORT
%
s TO
%
s"
%
\
(
self
.
user
,
port
,
self
.
host
),
host
=
self
.
host
)
(
self
.
user
,
port
,
self
.
host
),
host
=
self
.
host
)
netloc
=
'
%
s:
%
d'
%
(
self
.
host
,
port
)
netloc
=
'
%
s:
%
d'
%
(
self
.
host
,
port
)
cache_key
=
'
%
s:
%
s@
%
s:
%
d'
%
(
self
.
user
,
hashlib
.
md5
(
self
.
password
)
.
hexdigest
(),
self
.
host
,
port
)
if
cache_key
in
_winrm_cache
:
vvvv
(
'WINRM REUSE EXISTING CONNECTION:
%
s'
%
cache_key
,
host
=
self
.
host
)
return
_winrm_cache
[
cache_key
]
exc
=
None
exc
=
None
for
transport
,
scheme
in
self
.
transport_schemes
[
'http'
if
port
==
5985
else
'https'
]:
for
transport
,
scheme
in
self
.
transport_schemes
[
'http'
if
port
==
5985
else
'https'
]:
if
transport
==
'kerberos'
and
not
HAVE_KERBEROS
:
if
transport
==
'kerberos'
and
(
not
HAVE_KERBEROS
or
not
'@'
in
self
.
user
)
:
continue
continue
if
transport
==
'kerberos'
:
realm
=
self
.
user
.
split
(
'@'
,
1
)[
1
]
.
strip
()
or
None
else
:
realm
=
None
endpoint
=
urlparse
.
urlunsplit
((
scheme
,
netloc
,
'/wsman'
,
''
,
''
))
endpoint
=
urlparse
.
urlunsplit
((
scheme
,
netloc
,
'/wsman'
,
''
,
''
))
vvvv
(
'WINRM CONNECT: transport=
%
s endpoint=
%
s'
%
(
transport
,
endpoint
),
vvvv
(
'WINRM CONNECT: transport=
%
s endpoint=
%
s'
%
(
transport
,
endpoint
),
host
=
self
.
host
)
host
=
self
.
host
)
protocol
=
Protocol
(
endpoint
,
transport
=
transport
,
protocol
=
Protocol
(
endpoint
,
transport
=
transport
,
username
=
self
.
user
,
password
=
self
.
password
)
username
=
self
.
user
,
password
=
self
.
password
,
realm
=
realm
)
try
:
try
:
protocol
.
send_message
(
''
)
protocol
.
send_message
(
''
)
_winrm_cache
[
cache_key
]
=
protocol
return
protocol
return
protocol
except
WinRMTransportError
,
exc
:
except
WinRMTransportError
,
exc
:
err_msg
=
str
(
exc
)
err_msg
=
str
(
exc
)
...
@@ -111,7 +105,6 @@ class Connection(object):
...
@@ -111,7 +105,6 @@ class Connection(object):
if
code
==
401
:
if
code
==
401
:
raise
errors
.
AnsibleError
(
"the username/password specified for this server was incorrect"
)
raise
errors
.
AnsibleError
(
"the username/password specified for this server was incorrect"
)
elif
code
==
411
:
elif
code
==
411
:
_winrm_cache
[
cache_key
]
=
protocol
return
protocol
return
protocol
vvvv
(
'WINRM CONNECTION ERROR:
%
s'
%
err_msg
,
host
=
self
.
host
)
vvvv
(
'WINRM CONNECTION ERROR:
%
s'
%
err_msg
,
host
=
self
.
host
)
continue
continue
...
...
lib/ansible/runner/shell_plugins/powershell.py
View file @
a90bb89b
...
@@ -57,7 +57,7 @@ def _build_file_cmd(cmd_parts, quote_args=True):
...
@@ -57,7 +57,7 @@ def _build_file_cmd(cmd_parts, quote_args=True):
'''Build command line to run a file, given list of file name plus args.'''
'''Build command line to run a file, given list of file name plus args.'''
if
quote_args
:
if
quote_args
:
cmd_parts
=
[
'"
%
s"'
%
x
for
x
in
cmd_parts
]
cmd_parts
=
[
'"
%
s"'
%
x
for
x
in
cmd_parts
]
return
' '
.
join
(
[
'&
'
]
+
cmd_parts
)
return
' '
.
join
(
_common_args
+
[
'-ExecutionPolicy'
,
'Unrestricted'
,
'-File
'
]
+
cmd_parts
)
class
ShellModule
(
object
):
class
ShellModule
(
object
):
...
...
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