From 074305a67d7a81e7f5af502047b4855023e247fb Mon Sep 17 00:00:00 2001 From: Phil Schwartz Date: Tue, 30 Dec 2014 09:54:22 -0600 Subject: [PATCH] specifies creation of directory if !exists - added try catch for creation of directory, in case of an invalid path specified - added specification to documentation --- lib/ansible/modules/extras/windows/win_unzip.ps1 | 7 ++++++- lib/ansible/modules/extras/windows/win_unzip.py | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) 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: []