mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-23 00:30:22 -07:00
removes restart functionality, and added creates param for idempotency
This commit is contained in:
parent
af660c38fa
commit
2d1189dee8
2 changed files with 15 additions and 42 deletions
|
@ -26,6 +26,13 @@ $result = New-Object psobject @{
|
|||
changed = $false
|
||||
}
|
||||
|
||||
If ($params.creates) {
|
||||
If (Test-Path $params.creates) {
|
||||
Exit-Json $result "The 'creates' file or directory already exists."
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
If ($params.src) {
|
||||
$src = $params.src.toString()
|
||||
|
||||
|
@ -86,7 +93,7 @@ Else {
|
|||
$list = Get-Module -ListAvailable
|
||||
|
||||
If (-Not ($list -match "PSCX")) {
|
||||
Fail-Json "PowerShellCommunityExtensions PowerShell Module (PSCX) is required for non-'.zip' compressed archive types."
|
||||
Fail-Json $result "PowerShellCommunityExtensions PowerShell Module (PSCX) is required for non-'.zip' compressed archive types."
|
||||
}
|
||||
Else {
|
||||
Set-Attr $result.win_unzip "pscx_status" "present"
|
||||
|
@ -122,10 +129,10 @@ Else {
|
|||
}
|
||||
Catch {
|
||||
If ($recurse) {
|
||||
Fail-Json "Error recursively expanding $src to $dest"
|
||||
Fail-Json $result "Error recursively expanding $src to $dest"
|
||||
}
|
||||
Else {
|
||||
Fail-Json "Error expanding $src to $dest"
|
||||
Fail-Json $result "Error expanding $src to $dest"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -135,11 +142,6 @@ If ($rm -eq $true){
|
|||
Set-Attr $result.win_unzip "rm" "true"
|
||||
}
|
||||
|
||||
If ($params.restart -eq "true" -Or $params.restart -eq "yes") {
|
||||
Restart-Computer -Force
|
||||
Set-Attr $result.win_unzip "restart" "true"
|
||||
}
|
||||
|
||||
# Fixes a fail error message (when the task actually succeeds) for a "Convert-ToJson: The converted JSON string is in bad format"
|
||||
# This happens when JSON is parsing a string that ends with a "\", which is possible when specifying a directory to download to.
|
||||
# This catches that possible error, before assigning the JSON $result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue