diff --git a/windows/win_unzip.ps1 b/windows/win_unzip.ps1 index 8e6db762fe1..35a55c811c4 100644 --- a/windows/win_unzip.ps1 +++ b/windows/win_unzip.ps1 @@ -1,7 +1,7 @@ #!powershell # This file is part of Ansible # -# Copyright 2014, Phil Schwartz +# Copyright 2015, Phil Schwartz # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -80,43 +80,13 @@ If ($ext -eq ".zip" -And $recurse -eq $false) { Fail-Json $result "Error unzipping $src to $dest" } } -# Need PSCX +# Requires PSCX Else { - # Requires PSCX, will be installed if it isn't found - # Pscx-3.2.0.msi - $url = "http://download-codeplex.sec.s-msft.com/Download/Release?ProjectName=pscx&DownloadId=923562&FileTime=130585918034470000&Build=20959" - $msi = "C:\Pscx-3.2.0.msi" - # Check if PSCX is installed $list = Get-Module -ListAvailable - # If not download it and install + If (-Not ($list -match "PSCX")) { - # Try install with chocolatey - Try { - cinst -force PSCX -y - $choco = $true - } - Catch { - $choco = $false - } - # install from downloaded msi if choco failed or is not present - If ($choco -eq $false) { - Try { - $client = New-Object System.Net.WebClient - $client.DownloadFile($url, $msi) - } - Catch { - Fail-Json $result "Error downloading PSCX from $url and saving as $dest" - } - Try { - Start-Process -FilePath msiexec.exe -ArgumentList "/i $msi /qb" -Verb Runas -PassThru -Wait | out-null - } - Catch { - Fail-Json $result "Error installing $msi" - } - } - Set-Attr $result.win_zip "pscx_status" "pscx was installed" - $installed = $true + Fail-Json "PowerShellCommunityExtensions PowerShell Module (PSCX) is required for non-'.zip' compressed archive types." } Else { Set-Attr $result.win_zip "pscx_status" "present" @@ -124,17 +94,7 @@ Else { # Import Try { - If ($installed) { - Try { - Import-Module 'C:\Program Files (x86)\Powershell Community Extensions\pscx3\pscx\pscx.psd1' - } - Catch { - Import-Module PSCX - } - } - Else { - Import-Module PSCX - } + Import-Module PSCX } Catch { Fail-Json $result "Error importing module PSCX" @@ -193,4 +153,4 @@ Set-Attr $result.win_unzip "src" $src.toString() Set-Attr $result.win_unzip "dest" $dest.toString() Set-Attr $result.win_unzip "recurse" $recurse.toString() -Exit-Json $result; +Exit-Json $result; \ No newline at end of file diff --git a/windows/win_unzip.py b/windows/win_unzip.py index 35093aa8c76..2c3c41df0b7 100644 --- a/windows/win_unzip.py +++ b/windows/win_unzip.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# (c) 2014, Phil Schwartz +# (c) 2015, Phil Schwartz # # This file is part of Ansible # @@ -74,7 +74,7 @@ options: required: false default: false aliases: [] -author: Phil Schwartz +author: Phil Schwartz ''' EXAMPLES = ''' @@ -126,4 +126,17 @@ $ ansible -i hosts -m win_unzip -a "src=C:\\LibraryToUnzip.zip dest=C:\\Lib rm=t delay=15 timeout=600 state=started + +# Install PSCX to use for extracting a gz file + - name: Grab PSCX msi + win_get_url: + url: 'http://download-codeplex.sec.s-msft.com/Download/Release?ProjectName=pscx&DownloadId=923562&FileTime=130585918034470000&Build=20959' + dest: 'C:\\pscx.msi' + - name: Install PSCX + win_msi: + path: 'C:\\pscx.msi' + - name: Unzip gz log + win_unzip: + src: "C:\\Logs\\application-error-logs.gz" + dest: "C:\\ExtractedLogs\\application-error-logs" '''