@ -17,30 +17,25 @@
# WANT_JSON
# WANT_JSON
# POWERSHELL_COMMON
# POWERSHELL_COMMON
$params = Parse-Args $args $true ;
$params = Parse-Args $args -supports_check_mode $true ;
$src = Get-AnsibleParam -obj $params -name " src " -type " path " -aliases " path " -failifempty $true ;
$src = Get-Attr $params " src " ( Get-Attr $params " path " $FALSE ) ;
$result = @ {
If ( -not $src )
changed = $false ;
{
Fail-Json ( New-Object psobject ) " missing required argument: src " ;
}
}
If ( Test-Path -Path Type Leaf $src )
If ( Test-Path -Path $src -Path Type Leaf )
{
{
$bytes = [ System.IO.File ] :: ReadAllBytes ( $src ) ;
$bytes = [ System.IO.File ] :: ReadAllBytes ( $src ) ;
$content = [ System.Convert ] :: ToBase64String ( $bytes ) ;
$result . content = [ System.Convert ] :: ToBase64String ( $bytes ) ;
$result = New-Object psobject @ {
$result . encoding = " base64 " ;
changed = $false
encoding = " base64 "
content = $content
} ;
Exit-Json $result ;
Exit-Json $result ;
}
}
ElseIf ( Test-Path -Path Type Container $src )
ElseIf ( Test-Path -Path $src -PathType Container )
{
{
Fail-Json ( New-Object psobject ) ( " is a directory: " + $src ) ;
Fail-Json $result " Path $src is a directory " ;
}
}
Else
Else
{
{
Fail-Json ( New-Object psobject ) ( " file not found: " + $src ) ;
Fail-Json $result " Path $src is not found " ;
}
}