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
8dd3d842
Commit
8dd3d842
authored
Dec 01, 2014
by
Chris Church
Committed by
James Cammarata
Dec 04, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix PowerShell plugin issues affecting fetch module when used against Windows hosts.
parent
e728ff97
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
8 deletions
+21
-8
lib/ansible/runner/__init__.py
+1
-1
lib/ansible/runner/connection_plugins/winrm.py
+1
-1
lib/ansible/runner/shell_plugins/powershell.py
+14
-2
test/integration/roles/test_win_fetch/tasks/main.yml
+5
-4
No files found.
lib/ansible/runner/__init__.py
View file @
8dd3d842
...
...
@@ -1193,7 +1193,7 @@ class Runner(object):
return
path
if
len
(
split_path
)
>
1
:
return
os
.
path
.
join
(
initial_fragment
,
*
split_path
[
1
:])
return
conn
.
shell
.
join_path
(
initial_fragment
,
*
split_path
[
1
:])
else
:
return
initial_fragment
...
...
lib/ansible/runner/connection_plugins/winrm.py
View file @
8dd3d842
...
...
@@ -193,7 +193,7 @@ class Connection(object):
def
fetch_file
(
self
,
in_path
,
out_path
):
out_path
=
out_path
.
replace
(
'
\\
'
,
'/'
)
vvv
(
"FETCH
%
s TO
%
s"
%
(
in_path
,
out_path
),
host
=
self
.
host
)
buffer_size
=
2
**
20
# 1
MB chunks
buffer_size
=
2
**
19
# 0.5
MB chunks
if
not
os
.
path
.
exists
(
os
.
path
.
dirname
(
out_path
)):
os
.
makedirs
(
os
.
path
.
dirname
(
out_path
))
out_file
=
None
...
...
lib/ansible/runner/shell_plugins/powershell.py
View file @
8dd3d842
...
...
@@ -84,12 +84,24 @@ class ShellModule(object):
# FIXME: Support system temp path!
return
_encode_script
(
'''(New-Item -Type Directory -Path $env:temp -Name "
%
s").FullName | Write-Host -Separator '';'''
%
basefile
)
def
md5
(
self
,
path
):
def
expand_user
(
self
,
user_home_path
):
# PowerShell only supports "~" (not "~username"). Resolve-Path ~ does
# not seem to work remotely, though by default we are always starting
# in the user's home directory.
if
user_home_path
==
'~'
:
script
=
'Write-Host (Get-Location).Path'
elif
user_home_path
.
startswith
(
'~
\\
'
):
script
=
'Write-Host ((Get-Location).Path + "
%
s")'
%
_escape
(
user_home_path
[
1
:])
else
:
script
=
'Write-Host "
%
s"'
%
_escape
(
user_home_path
)
return
_encode_script
(
script
)
def
checksum
(
self
,
path
,
python_interp
):
path
=
_escape
(
path
)
script
=
'''
If (Test-Path -PathType Leaf "
%(path)
s")
{
$sp = new-object -TypeName System.Security.Cryptography.
MD5
CryptoServiceProvider;
$sp = new-object -TypeName System.Security.Cryptography.
SHA1
CryptoServiceProvider;
$fp = [System.IO.File]::Open("
%(path)
s", [System.IO.Filemode]::Open, [System.IO.FileAccess]::Read);
[System.BitConverter]::ToString($sp.ComputeHash($fp)).Replace("-", "").ToLower();
$fp.Dispose();
...
...
test/integration/roles/test_win_fetch/tasks/main.yml
View file @
8dd3d842
...
...
@@ -18,11 +18,11 @@
-
name
:
clean out the test directory
local_action
:
file name={{ output_dir|mandatory }} state=absent
tags
:
m
e
run_once
:
tru
e
-
name
:
create the test directory
local_action
:
file name={{ output_dir }} state=directory
tags
:
m
e
run_once
:
tru
e
-
name
:
fetch a small file
fetch
:
src="C:/Windows/win.ini" dest={{ output_dir }}
...
...
@@ -145,7 +145,7 @@
-
"
not
fetch_missing_nofail|changed"
-
name
:
attempt to fetch a non-existent file - fail on missing
fetch
:
src="
C:
/this_file_should_not_exist.txt" dest={{ output_dir }} fail_on_missing=yes
fetch
:
src="
~
/this_file_should_not_exist.txt" dest={{ output_dir }} fail_on_missing=yes
register
:
fetch_missing
ignore_errors
:
true
...
...
@@ -164,5 +164,6 @@
-
name
:
check fetch directory result
assert
:
that
:
-
"
fetch_dir|failed"
# Doesn't fail anymore, only returns a message.
-
"
not
fetch_dir|changed"
-
"
fetch_dir.msg"
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