From 9cd6f1bf918de53dc22a2521c2703b38a6967355 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Tue, 23 May 2017 19:46:13 +0200 Subject: [PATCH] win_copy: Fix recursive copy (#23581) This fixes #23559. This should be backported to v2.3 branch too. --- lib/ansible/modules/windows/win_copy.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/windows/win_copy.ps1 b/lib/ansible/modules/windows/win_copy.ps1 index 84e9e93f99..e3f081df4f 100644 --- a/lib/ansible/modules/windows/win_copy.ps1 +++ b/lib/ansible/modules/windows/win_copy.ps1 @@ -32,8 +32,9 @@ $original_basename = Get-AnsibleParam -obj $params -name "original_basename" -ty $result = @{ changed = $false - src = $src dest = $dest + original_basename = $original_basename + src = $src } if (($force -eq $false) -and (Test-Path -Path $dest)) { @@ -122,6 +123,9 @@ if ($original_basename) { } catch { Fail-Json $result "Failed to create directory $($dest_folder): $($_.Exception.Message)" } + } + + if ((Get-Item -Path $dest -Force).PSIsContainer) { $dest = Join-Path $dest -ChildPath $original_basename } }