mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Switching to Get-AnsibleParam
Switching to Win_Unzip
This commit is contained in:
parent
34ff61e24f
commit
e0fa5fa74c
1 changed files with 17 additions and 39 deletions
|
@ -26,55 +26,33 @@ $result = New-Object psobject @{
|
||||||
changed = $false
|
changed = $false
|
||||||
}
|
}
|
||||||
|
|
||||||
If (Get-Member -InputObject $params -Name creates) {
|
$creates = Get-AnsibleParam -obj $params -name "creates"
|
||||||
|
If ($creates -ne $null) {
|
||||||
If (Test-Path $params.creates) {
|
If (Test-Path $params.creates) {
|
||||||
Exit-Json $result "The 'creates' file or directory already exists."
|
Exit-Json $result "The 'creates' file or directory already exists."
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
If (Get-Member -InputObject $params -Name src) {
|
$src = Get-AnsibleParam -obj $params -name "src" -failifempty $true
|
||||||
$src = $params.src.toString()
|
If (-Not (Test-Path -path $src)){
|
||||||
|
Fail-Json $result "src file: $src does not exist."
|
||||||
|
}
|
||||||
|
|
||||||
If (-Not (Test-Path -path $src)){
|
$ext = [System.IO.Path]::GetExtension($src)
|
||||||
Fail-Json $result "src file: $src does not exist."
|
|
||||||
|
|
||||||
|
$dest = Get-AnsibleParam -obj $params -name "dest" -failifempty $true
|
||||||
|
If (-Not (Test-Path $dest -PathType Container)){
|
||||||
|
Try{
|
||||||
|
New-Item -itemtype directory -path $dest
|
||||||
}
|
}
|
||||||
|
Catch {
|
||||||
$ext = [System.IO.Path]::GetExtension($src)
|
Fail-Json $result "Error creating $dest directory"
|
||||||
}
|
|
||||||
Else {
|
|
||||||
Fail-Json $result "missing required argument: src"
|
|
||||||
}
|
|
||||||
|
|
||||||
If (-Not($params.dest -eq $null)) {
|
|
||||||
$dest = $params.dest.toString()
|
|
||||||
|
|
||||||
If (-Not (Test-Path $dest -PathType Container)){
|
|
||||||
Try{
|
|
||||||
New-Item -itemtype directory -path $dest
|
|
||||||
}
|
|
||||||
Catch {
|
|
||||||
Fail-Json $result "Error creating $dest directory"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Else {
|
|
||||||
Fail-Json $result "missing required argument: dest"
|
|
||||||
}
|
|
||||||
|
|
||||||
If (Get-Member -InputObject $params -Name recurse) {
|
$recurse = ConvertTo-Bool (Get-AnsibleParam -obj $params -name "recurse" -default "false")
|
||||||
$recurse = ConvertTo-Bool ($params.recurse)
|
$rm = ConvertTo-Bool (Get-AnsibleParam -obj $params -name "rm" -default "false")
|
||||||
}
|
|
||||||
Else {
|
|
||||||
$recurse = $false
|
|
||||||
}
|
|
||||||
|
|
||||||
If (Get-Member -InputObject $params -Name rm) {
|
|
||||||
$rm = ConvertTo-Bool ($params.rm)
|
|
||||||
}
|
|
||||||
Else {
|
|
||||||
$rm = $false
|
|
||||||
}
|
|
||||||
|
|
||||||
If ($ext -eq ".zip" -And $recurse -eq $false) {
|
If ($ext -eq ".zip" -And $recurse -eq $false) {
|
||||||
Try {
|
Try {
|
||||||
|
|
Loading…
Reference in a new issue