From e065b48c9c2a21ac7832fae88250606284b0a743 Mon Sep 17 00:00:00 2001 From: Brandon Adams Date: Thu, 26 Sep 2024 14:39:58 -0400 Subject: [PATCH 1/5] Add cluster IP information during AddNode operation. Style fixes per configuration --- .../DSC_SqlSetup/DSC_SqlSetup.psm1 | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 b/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 index 029f964b7..33dac636d 100644 --- a/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 +++ b/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 @@ -63,7 +63,7 @@ $script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' #> function Get-TargetResource { - [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('SqlServerDsc.AnalyzerRules\Measure-CommandsNeededToLoadSMO', '', Justification='The command Connect-Sql is called implicitly in several function, for example Get-SqlEngineProperties')] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('SqlServerDsc.AnalyzerRules\Measure-CommandsNeededToLoadSMO', '', Justification = 'The command Connect-Sql is called implicitly in several function, for example Get-SqlEngineProperties')] [CmdletBinding()] [OutputType([System.Collections.Hashtable])] param @@ -722,8 +722,8 @@ function Get-TargetResource #> function Set-TargetResource { - [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars', '', Justification='Because $global:DSCMachineStatus is used to trigger a Restart, either by force or when there are pending changes.')] - [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification='Because $global:DSCMachineStatus is only set, never used (by design of Desired State Configuration).')] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars', '', Justification = 'Because $global:DSCMachineStatus is used to trigger a Restart, either by force or when there are pending changes.')] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Because $global:DSCMachineStatus is only set, never used (by design of Desired State Configuration).')] [CmdletBinding()] param ( @@ -1265,15 +1265,17 @@ function Set-TargetResource $setupArguments['FailoverClusterDisks'] = ($failoverClusterDisks | Sort-Object) } + # Determine network mapping for specific cluster installation types - if ($Action -in @('CompleteFailoverCluster', 'InstallFailoverCluster')) + if ($Action -in @('CompleteFailoverCluster', 'InstallFailoverCluster', 'AddNode')) { + Write-Warning 'Inside the IP Address stuff' $clusterIPAddresses = @() # If no IP Address has been specified, use "DEFAULT" if ($FailoverClusterIPAddress.Count -eq 0) { - $clusterIPAddresses += "DEFAULT" + $clusterIPAddresses += 'DEFAULT' } else { @@ -1525,7 +1527,7 @@ function Set-TargetResource $setupArguments['ASSysAdminAccounts'] = @($PsDscContext.RunAsUser) } - if ($PSBoundParameters.ContainsKey("ASSysAdminAccounts")) + if ($PSBoundParameters.ContainsKey('ASSysAdminAccounts')) { $setupArguments['ASSysAdminAccounts'] += $ASSysAdminAccounts } @@ -1636,12 +1638,12 @@ function Set-TargetResource if ($SecurityMode -eq 'SQL') { - $log = $log.Replace($SAPwd.GetNetworkCredential().Password, "********") + $log = $log.Replace($SAPwd.GetNetworkCredential().Password, '********') } - if ($ProductKey -ne "") + if ($ProductKey -ne '') { - $log = $log.Replace($ProductKey, "*****-*****-*****-*****-*****") + $log = $log.Replace($ProductKey, '*****-*****-*****-*****-*****') } $logVars = @('AgtSvcAccount', 'SQLSvcAccount', 'FTSvcAccount', 'RSSvcAccount', 'ASSvcAccount', 'ISSvcAccount') @@ -1649,7 +1651,7 @@ function Set-TargetResource { if ($PSBoundParameters.ContainsKey($logVar)) { - $log = $log.Replace((Get-Variable -Name $logVar).Value.GetNetworkCredential().Password, "********") + $log = $log.Replace((Get-Variable -Name $logVar).Value.GetNetworkCredential().Password, '********') } } @@ -1996,7 +1998,7 @@ function Set-TargetResource #> function Test-TargetResource { - [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('SqlServerDsc.AnalyzerRules\Measure-CommandsNeededToLoadSMO', '', Justification='The command Connect-Sql is implicitly called when Get-TargetResource is called')] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('SqlServerDsc.AnalyzerRules\Measure-CommandsNeededToLoadSMO', '', Justification = 'The command Connect-Sql is implicitly called when Get-TargetResource is called')] [CmdletBinding()] [OutputType([System.Boolean])] param @@ -2342,7 +2344,7 @@ function Test-TargetResource Write-Verbose -Message $script:localizedData.EvaluatingClusterParameters $variableNames = $PSBoundParameters.Keys | - Where-Object -FilterScript { $_ -imatch "^FailoverCluster" } + Where-Object -FilterScript { $_ -imatch '^FailoverCluster' } foreach ($variableName in $variableNames) { From 28fead45175e9bc394244e3efb5d97cd9e4c7aa7 Mon Sep 17 00:00:00 2001 From: Brandon Adams Date: Thu, 26 Sep 2024 14:42:41 -0400 Subject: [PATCH 2/5] Update unit test for AddNode in SqlSetup to ensure IP information is in setup command. --- tests/Unit/DSC_SqlSetup.Tests.ps1 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/Unit/DSC_SqlSetup.Tests.ps1 b/tests/Unit/DSC_SqlSetup.Tests.ps1 index b0f66d8e2..272ba8e41 100644 --- a/tests/Unit/DSC_SqlSetup.Tests.ps1 +++ b/tests/Unit/DSC_SqlSetup.Tests.ps1 @@ -3226,6 +3226,22 @@ Describe 'SqlSetup\Set-TargetResource' -Tag 'Set' { Features = '' } } + + $mockDynamicClusterSites = @( + @{ + Name = 'SiteA' + Address = '10.0.0.10' # First site IP address + Mask = '255.255.255.0' + } + ) + + Mock -CommandName Get-CimInstance -MockWith $mockGetCimInstance_MSClusterNetwork -ParameterFilter { + ($Namespace -eq 'root/MSCluster') -and ($ClassName -eq 'MSCluster_Network') -and ($Filter -eq 'Role >= 2') + } + + Mock -CommandName Test-IPAddress -MockWith { + return $true + } } It 'Should pass proper parameters to setup' { @@ -3240,6 +3256,7 @@ Describe 'SqlSetup\Set-TargetResource' -Tag 'Set' { SqlSvcPassword = 'SqlS3v!c3P@ssw0rd' AsSvcAccount = 'COMPANY\AnalysisAccount' AsSvcPassword = 'AnalysisS3v!c3P@ssw0rd' + FailoverClusterIPAddresses = 'IPv4;10.0.0.10;SiteA_Prod;255.255.255.0' } InModuleScope -ScriptBlock { @@ -3255,6 +3272,7 @@ Describe 'SqlSetup\Set-TargetResource' -Tag 'Set' { SqlSvcAccount = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList @('COMPANY\SqlAccount', ('SqlS3v!c3P@ssw0rd' | ConvertTo-SecureString -AsPlainText -Force)) ASSvcAccount = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList @('COMPANY\AnalysisAccount', ('AnalysisS3v!c3P@ssw0rd' | ConvertTo-SecureString -AsPlainText -Force)) FailoverClusterNetworkName = 'TestDefaultCluster' + FailoverClusterIPAddress = '10.0.0.10' SQLSysAdminAccounts = 'COMPANY\User1', 'COMPANY\SQLAdmins' } From 850966e907cb847939b9676ed866fbaf4a9c4f07 Mon Sep 17 00:00:00 2001 From: Brandon Adams Date: Thu, 26 Sep 2024 15:00:58 -0400 Subject: [PATCH 3/5] Remove warning message for testing purposes. --- source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 | 1 - 1 file changed, 1 deletion(-) diff --git a/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 b/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 index 33dac636d..24056b34f 100644 --- a/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 +++ b/source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1 @@ -1269,7 +1269,6 @@ function Set-TargetResource # Determine network mapping for specific cluster installation types if ($Action -in @('CompleteFailoverCluster', 'InstallFailoverCluster', 'AddNode')) { - Write-Warning 'Inside the IP Address stuff' $clusterIPAddresses = @() # If no IP Address has been specified, use "DEFAULT" From c860648247361d7915e5b14f22b6a2247cc522e3 Mon Sep 17 00:00:00 2001 From: nabrond Date: Wed, 2 Oct 2024 11:06:46 -0400 Subject: [PATCH 4/5] Update CHANGELOG accordingly. --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e3e48e20..e95c60c5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- SqlSetup + - Fixed issue with AddNode where cluster IP information was not being passed to + setup.exe. ([issue #1171](https://github.com/dsccommunity/SqlServerDsc/issues/1171)) + ## [17.0.0] - 2024-09-30 ### Added From c8cbea416428814098fdd8e7804cc678dfbcf39d Mon Sep 17 00:00:00 2001 From: nabrond Date: Wed, 2 Oct 2024 14:24:25 -0400 Subject: [PATCH 5/5] Fix README to remove note about AddNode not working. --- source/DSCResources/DSC_SqlSetup/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/DSCResources/DSC_SqlSetup/README.md b/source/DSCResources/DSC_SqlSetup/README.md index 30f58cb7f..f2e4c9cd1 100644 --- a/source/DSCResources/DSC_SqlSetup/README.md +++ b/source/DSCResources/DSC_SqlSetup/README.md @@ -156,5 +156,3 @@ AnalysisServicesConnection | A new method of loading the assembly *Microsoft.Ana ## Known issues 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). - -> [!IMPORTANT] The setup action AddNode is not currently functional.