Skip to content

Commit 5677cd5

Browse files
authored
SqlSetup: Fix AddNode failing due to missing setup parameters (#2047)
1 parent 6d8e2ff commit 5677cd5

File tree

4 files changed

+35
-14
lines changed

4 files changed

+35
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
55

66
## [Unreleased]
77

8+
- SqlSetup
9+
- Fixed issue with AddNode where cluster IP information was not being passed to
10+
setup.exe. ([issue #1171](https://github.com/dsccommunity/SqlServerDsc/issues/1171))
11+
812
## [17.0.0] - 2024-09-30
913

1014
### Added

source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ $script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'
6363
#>
6464
function Get-TargetResource
6565
{
66-
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('SqlServerDsc.AnalyzerRules\Measure-CommandsNeededToLoadSMO', '', Justification='The command Connect-Sql is called implicitly in several function, for example Get-SqlEngineProperties')]
66+
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('SqlServerDsc.AnalyzerRules\Measure-CommandsNeededToLoadSMO', '', Justification = 'The command Connect-Sql is called implicitly in several function, for example Get-SqlEngineProperties')]
6767
[CmdletBinding()]
6868
[OutputType([System.Collections.Hashtable])]
6969
param
@@ -722,8 +722,8 @@ function Get-TargetResource
722722
#>
723723
function Set-TargetResource
724724
{
725-
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars', '', Justification='Because $global:DSCMachineStatus is used to trigger a Restart, either by force or when there are pending changes.')]
726-
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification='Because $global:DSCMachineStatus is only set, never used (by design of Desired State Configuration).')]
725+
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars', '', Justification = 'Because $global:DSCMachineStatus is used to trigger a Restart, either by force or when there are pending changes.')]
726+
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Because $global:DSCMachineStatus is only set, never used (by design of Desired State Configuration).')]
727727
[CmdletBinding()]
728728
param
729729
(
@@ -1265,15 +1265,16 @@ function Set-TargetResource
12651265
$setupArguments['FailoverClusterDisks'] = ($failoverClusterDisks | Sort-Object)
12661266
}
12671267

1268+
12681269
# Determine network mapping for specific cluster installation types
1269-
if ($Action -in @('CompleteFailoverCluster', 'InstallFailoverCluster'))
1270+
if ($Action -in @('CompleteFailoverCluster', 'InstallFailoverCluster', 'AddNode'))
12701271
{
12711272
$clusterIPAddresses = @()
12721273

12731274
# If no IP Address has been specified, use "DEFAULT"
12741275
if ($FailoverClusterIPAddress.Count -eq 0)
12751276
{
1276-
$clusterIPAddresses += "DEFAULT"
1277+
$clusterIPAddresses += 'DEFAULT'
12771278
}
12781279
else
12791280
{
@@ -1525,7 +1526,7 @@ function Set-TargetResource
15251526
$setupArguments['ASSysAdminAccounts'] = @($PsDscContext.RunAsUser)
15261527
}
15271528

1528-
if ($PSBoundParameters.ContainsKey("ASSysAdminAccounts"))
1529+
if ($PSBoundParameters.ContainsKey('ASSysAdminAccounts'))
15291530
{
15301531
$setupArguments['ASSysAdminAccounts'] += $ASSysAdminAccounts
15311532
}
@@ -1636,20 +1637,20 @@ function Set-TargetResource
16361637

16371638
if ($SecurityMode -eq 'SQL')
16381639
{
1639-
$log = $log.Replace($SAPwd.GetNetworkCredential().Password, "********")
1640+
$log = $log.Replace($SAPwd.GetNetworkCredential().Password, '********')
16401641
}
16411642

1642-
if ($ProductKey -ne "")
1643+
if ($ProductKey -ne '')
16431644
{
1644-
$log = $log.Replace($ProductKey, "*****-*****-*****-*****-*****")
1645+
$log = $log.Replace($ProductKey, '*****-*****-*****-*****-*****')
16451646
}
16461647

16471648
$logVars = @('AgtSvcAccount', 'SQLSvcAccount', 'FTSvcAccount', 'RSSvcAccount', 'ASSvcAccount', 'ISSvcAccount')
16481649
foreach ($logVar in $logVars)
16491650
{
16501651
if ($PSBoundParameters.ContainsKey($logVar))
16511652
{
1652-
$log = $log.Replace((Get-Variable -Name $logVar).Value.GetNetworkCredential().Password, "********")
1653+
$log = $log.Replace((Get-Variable -Name $logVar).Value.GetNetworkCredential().Password, '********')
16531654
}
16541655
}
16551656

@@ -1996,7 +1997,7 @@ function Set-TargetResource
19961997
#>
19971998
function Test-TargetResource
19981999
{
1999-
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('SqlServerDsc.AnalyzerRules\Measure-CommandsNeededToLoadSMO', '', Justification='The command Connect-Sql is implicitly called when Get-TargetResource is called')]
2000+
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('SqlServerDsc.AnalyzerRules\Measure-CommandsNeededToLoadSMO', '', Justification = 'The command Connect-Sql is implicitly called when Get-TargetResource is called')]
20002001
[CmdletBinding()]
20012002
[OutputType([System.Boolean])]
20022003
param
@@ -2342,7 +2343,7 @@ function Test-TargetResource
23422343
Write-Verbose -Message $script:localizedData.EvaluatingClusterParameters
23432344

23442345
$variableNames = $PSBoundParameters.Keys |
2345-
Where-Object -FilterScript { $_ -imatch "^FailoverCluster" }
2346+
Where-Object -FilterScript { $_ -imatch '^FailoverCluster' }
23462347

23472348
foreach ($variableName in $variableNames)
23482349
{

source/DSCResources/DSC_SqlSetup/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,5 +156,3 @@ AnalysisServicesConnection | A new method of loading the assembly *Microsoft.Ana
156156
## Known issues
157157

158158
All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlSetup).
159-
160-
> [!IMPORTANT] The setup action AddNode is not currently functional.

tests/Unit/DSC_SqlSetup.Tests.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3226,6 +3226,22 @@ Describe 'SqlSetup\Set-TargetResource' -Tag 'Set' {
32263226
Features = ''
32273227
}
32283228
}
3229+
3230+
$mockDynamicClusterSites = @(
3231+
@{
3232+
Name = 'SiteA'
3233+
Address = '10.0.0.10' # First site IP address
3234+
Mask = '255.255.255.0'
3235+
}
3236+
)
3237+
3238+
Mock -CommandName Get-CimInstance -MockWith $mockGetCimInstance_MSClusterNetwork -ParameterFilter {
3239+
($Namespace -eq 'root/MSCluster') -and ($ClassName -eq 'MSCluster_Network') -and ($Filter -eq 'Role >= 2')
3240+
}
3241+
3242+
Mock -CommandName Test-IPAddress -MockWith {
3243+
return $true
3244+
}
32293245
}
32303246

32313247
It 'Should pass proper parameters to setup' {
@@ -3240,6 +3256,7 @@ Describe 'SqlSetup\Set-TargetResource' -Tag 'Set' {
32403256
SqlSvcPassword = 'SqlS3v!c3P@ssw0rd'
32413257
AsSvcAccount = 'COMPANY\AnalysisAccount'
32423258
AsSvcPassword = 'AnalysisS3v!c3P@ssw0rd'
3259+
FailoverClusterIPAddresses = 'IPv4;10.0.0.10;SiteA_Prod;255.255.255.0'
32433260
}
32443261

32453262
InModuleScope -ScriptBlock {
@@ -3255,6 +3272,7 @@ Describe 'SqlSetup\Set-TargetResource' -Tag 'Set' {
32553272
SqlSvcAccount = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList @('COMPANY\SqlAccount', ('SqlS3v!c3P@ssw0rd' | ConvertTo-SecureString -AsPlainText -Force))
32563273
ASSvcAccount = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList @('COMPANY\AnalysisAccount', ('AnalysisS3v!c3P@ssw0rd' | ConvertTo-SecureString -AsPlainText -Force))
32573274
FailoverClusterNetworkName = 'TestDefaultCluster'
3275+
FailoverClusterIPAddress = '10.0.0.10'
32583276
SQLSysAdminAccounts = 'COMPANY\User1', 'COMPANY\SQLAdmins'
32593277
}
32603278

0 commit comments

Comments
 (0)