diff --git a/lib/ansible/modules/extras/windows/win_unzip.ps1 b/lib/ansible/modules/extras/windows/win_unzip.ps1 index de9fb73e7ce..e76c51dc6aa 100644 --- a/lib/ansible/modules/extras/windows/win_unzip.ps1 +++ b/lib/ansible/modules/extras/windows/win_unzip.ps1 @@ -41,7 +41,12 @@ If (-Not($params.dest -eq $null)) { $dest = $params.dest.toString() If (-Not (Test-Path $dest -PathType Container)){ - New-Item -itemtype directory -path $dest + Try{ + New-Item -itemtype directory -path $dest + } + Catch { + Fail-Json $result "Error creating $dest directory" + } } } Else { diff --git a/lib/ansible/modules/extras/windows/win_unzip.py b/lib/ansible/modules/extras/windows/win_unzip.py index ae2bfa94ad8..f9ba5ded0d0 100644 --- a/lib/ansible/modules/extras/windows/win_unzip.py +++ b/lib/ansible/modules/extras/windows/win_unzip.py @@ -27,7 +27,7 @@ module: win_unzip version_added: "" short_description: Unzips compressed files on the Windows node description: - - Unzips compressed files, and can force reboot (if needed, i.e. such as hotfixes). + - Unzips compressed files, and can force reboot (if needed, i.e. such as hotfixes). If the destination directory does not exist, it will be created before unzipping the file. Specifying rm parameter will allow removal of the zip file after extraction. options: zip: description: @@ -37,7 +37,7 @@ options: aliases: [] dest: description: - - Destination of zip file (provide absolute path of directory) + - Destination of zip file (provide absolute path of directory). If it does not exist, the directory will be created. required: true default: null aliases: []