mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
838 B
PowerShell
31 lines
838 B
PowerShell
7 years ago
|
#!powershell
|
||
|
|
||
|
#Requires -Module Ansible.ModuleUtils.Legacy
|
||
|
#Requires -Module Ansible.ModuleUtils.LinkUtil
|
||
|
|
||
|
$params = Parse-Args $args
|
||
|
|
||
|
$state = Get-AnsibleParam -obj $params -name "state" -type "str" -default "present" -validateset "absent","present"
|
||
|
$src = Get-AnsibleParam -obj $params -name "src" -type "path" -failifempty $true
|
||
|
$target = Get-AnsibleParam -obj $params -name "target" -type "path" -failifempty $($state -eq "present")
|
||
|
|
||
|
$result = @{
|
||
|
changed = $false
|
||
|
}
|
||
|
|
||
|
if ($state -eq "absent") {
|
||
|
if (Test-Path -Path $src) {
|
||
|
Load-LinkUtils
|
||
|
Remove-Link -link_path $src
|
||
|
$result.changed = $true
|
||
|
}
|
||
|
} else {
|
||
|
if (-not (Test-Path -Path $src)) {
|
||
|
Load-LinkUtils
|
||
|
New-Link -link_path $src -link_target $target -link_type "link"
|
||
|
$result.changed = $true
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Exit-Json -obj $result
|