fixed tests after EAP set to Stop globally, ci_complete
This commit is contained in:
parent
cd4415d4ec
commit
e283e7d5dd
2 changed files with 211 additions and 200 deletions
|
@ -3,6 +3,8 @@
|
||||||
# Copyright: (c) 2015, Jon Hawkesworth (@jhawkesworth) <figs@unity.demon.co.uk>
|
# Copyright: (c) 2015, Jon Hawkesworth (@jhawkesworth) <figs@unity.demon.co.uk>
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
#Requires -Module Ansible.ModuleUtils.ArgvParser
|
||||||
|
#Requires -Module Ansible.ModuleUtils.CommandUtil
|
||||||
#Requires -Module Ansible.ModuleUtils.Legacy
|
#Requires -Module Ansible.ModuleUtils.Legacy
|
||||||
|
|
||||||
Function Convert-RegistryPath {
|
Function Convert-RegistryPath {
|
||||||
|
@ -46,24 +48,31 @@ If ( $do_comparison -eq $True ) {
|
||||||
$expanded_compare_key = Convert-RegistryPath ($compare_to_key)
|
$expanded_compare_key = Convert-RegistryPath ($compare_to_key)
|
||||||
|
|
||||||
# export from the reg key location to a file
|
# export from the reg key location to a file
|
||||||
$reg_args = @("EXPORT", "$expanded_compare_key", $exported_path)
|
$reg_args = Argv-ToString -Arguments @("reg.exe", "EXPORT", $expanded_compare_key, $exported_path)
|
||||||
& reg.exe $reg_args
|
$res = Run-Command -command $reg_args
|
||||||
|
if ($res.rc -ne 0) {
|
||||||
|
$result.rc = $res.rc
|
||||||
|
$result.stdout = $res.stdout
|
||||||
|
$result.stderr = $res.stderr
|
||||||
|
Fail-Json -obj $result -message "error exporting registry '$expanded_compare_key' to '$exported_path'"
|
||||||
|
}
|
||||||
|
|
||||||
# compare the two files
|
# compare the two files
|
||||||
$comparison_result = Compare-Object -ReferenceObject $(Get-Content $path) -DifferenceObject $(Get-Content $exported_path)
|
$comparison_result = Compare-Object -ReferenceObject $(Get-Content $path) -DifferenceObject $(Get-Content $exported_path)
|
||||||
|
|
||||||
If (Get-Member -InputObject $comparison_result -Name "count" -MemberType Properties )
|
If ($null -ne $comparison_result -and (Get-Member -InputObject $comparison_result -Name "count" -MemberType Properties ))
|
||||||
{
|
{
|
||||||
# Something is different, actually do reg merge
|
# Something is different, actually do reg merge
|
||||||
$reg_import_args = @("IMPORT", "$path")
|
$reg_import_args = Argv-ToString -Arguments @("reg.exe", "IMPORT", $path)
|
||||||
$ret = & reg.exe $reg_import_args 2>&1
|
$res = Run-Command -command $reg_import_args
|
||||||
If ($LASTEXITCODE -eq 0) {
|
if ($res.rc -ne 0) {
|
||||||
|
$result.rc = $res.rc
|
||||||
|
$result.stdout = $res.stdout
|
||||||
|
$result.stderr = $res.stderr
|
||||||
|
Fail-Json -obj $result -message "error importing registry values from '$path'"
|
||||||
|
}
|
||||||
$result.changed = $true
|
$result.changed = $true
|
||||||
$result.difference_count = $comparison_result.count
|
$result.difference_count = $comparison_result.count
|
||||||
} Else {
|
|
||||||
$result.rc = $LASTEXITCODE
|
|
||||||
Fail-Json $result "$ret"
|
|
||||||
}
|
|
||||||
} Else {
|
} Else {
|
||||||
$result.difference_count = 0
|
$result.difference_count = 0
|
||||||
}
|
}
|
||||||
|
@ -73,15 +82,16 @@ If ( $do_comparison -eq $True ) {
|
||||||
|
|
||||||
} Else {
|
} Else {
|
||||||
# not comparing, merge and report changed
|
# not comparing, merge and report changed
|
||||||
$reg_import_args = @("IMPORT", "$path")
|
$reg_import_args = Argv-ToString -Arguments @("reg.exe", "IMPORT", $path)
|
||||||
$ret = & reg.exe $reg_import_args 2>&1
|
$res = Run-Command -command $reg_import_args
|
||||||
If ( $LASTEXITCODE -eq 0 ) {
|
if ($res.rc -ne 0) {
|
||||||
|
$result.rc = $res.rc
|
||||||
|
$result.stdout = $res.stdout
|
||||||
|
$result.stderr = $res.stderr
|
||||||
|
Fail-Json -obj $result -message "error importing registry value from '$path'"
|
||||||
|
}
|
||||||
$result.changed = $true
|
$result.changed = $true
|
||||||
$result.compared = $false
|
$result.compared = $false
|
||||||
} Else {
|
|
||||||
$result.rc = $LASTEXITCODE
|
|
||||||
Fail-Json $result "$ret"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Exit-Json $result
|
Exit-Json $result
|
||||||
|
|
|
@ -52,9 +52,8 @@ if (-not (Get-Command -Name Get-SmbShare -ErrorAction SilentlyContinue)) {
|
||||||
Fail-Json $result "The current host does not support the -SmbShare cmdlets required by this module. Please run on Server 2012 or Windows 8 and later"
|
Fail-Json $result "The current host does not support the -SmbShare cmdlets required by this module. Please run on Server 2012 or Windows 8 and later"
|
||||||
}
|
}
|
||||||
|
|
||||||
Try {
|
$share = Get-SmbShare -Name $name -ErrorAction SilentlyContinue
|
||||||
$share = Get-SmbShare -Name $name -ErrorAction SilentlyContinue
|
If ($state -eq "absent") {
|
||||||
If ($state -eq "absent") {
|
|
||||||
If ($share) {
|
If ($share) {
|
||||||
# See message around -WhatIf where $check_mode is defined
|
# See message around -WhatIf where $check_mode is defined
|
||||||
if (-not $check_mode) {
|
if (-not $check_mode) {
|
||||||
|
@ -63,7 +62,7 @@ Try {
|
||||||
$result.actions += "Remove-SmbShare -Force -Name $name"
|
$result.actions += "Remove-SmbShare -Force -Name $name"
|
||||||
$result.changed = $true
|
$result.changed = $true
|
||||||
}
|
}
|
||||||
} Else {
|
} Else {
|
||||||
$path = Get-AnsibleParam -obj $params -name "path" -type "path" -failifempty $true
|
$path = Get-AnsibleParam -obj $params -name "path" -type "path" -failifempty $true
|
||||||
$description = Get-AnsibleParam -obj $params -name "description" -type "str" -default ""
|
$description = Get-AnsibleParam -obj $params -name "description" -type "str" -default ""
|
||||||
|
|
||||||
|
@ -94,6 +93,11 @@ Try {
|
||||||
|
|
||||||
$result.changed = $true
|
$result.changed = $true
|
||||||
$result.actions += "New-SmbShare -Name $name -Path $path"
|
$result.actions += "New-SmbShare -Name $name -Path $path"
|
||||||
|
# if in check mode we cannot run the below as no share exists so just
|
||||||
|
# exit early
|
||||||
|
if ($check_mode) {
|
||||||
|
Exit-Json -obj $result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
If ($share.Path -ne $path) {
|
If ($share.Path -ne $path) {
|
||||||
if (-not $check_mode) {
|
if (-not $check_mode) {
|
||||||
|
@ -239,9 +243,6 @@ Try {
|
||||||
$result.changed = $true
|
$result.changed = $true
|
||||||
$result.actions += "Block-SmbShareAccess -Force -Name $name -AccountName $user"
|
$result.actions += "Block-SmbShareAccess -Force -Name $name -AccountName $user"
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} Catch {
|
|
||||||
Fail-Json $result "an error occurred when attempting to create share $($name): $($_.Exception.Message)"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Exit-Json $result
|
Exit-Json $result
|
||||||
|
|
Loading…
Reference in a new issue