Skip to content

Commit

Permalink
SqlSetup: Added the properties NpEnabled and TcpEnabled (#1521)
Browse files Browse the repository at this point in the history
- SqlSetup
  - Added the properties `NpEnabled` and `TcpEnabled` (issue #1161).
  • Loading branch information
johlju authored May 6, 2020
1 parent e6cb820 commit 356c11a
Show file tree
Hide file tree
Showing 8 changed files with 339 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- SqlSetup
- A read only property `IsClustered` was added that can be used to determine
if the instance is clustered.
- Added the properties `NpEnabled` and `TcpEnabled` ([issue #1161](https://github.com/dsccommunity/SqlServerDsc/issues/1161)).
- SqlServerDsc.Common
- The helper function `Restart-SqlService` was improved to handle Failover
Clusters better. Now the SQL Server service will only be taken offline
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2126,6 +2126,12 @@ with different sizes and growths.
of each tempdb log file in MB.
* **`[UInt32]` SqlTempdbLogFileGrowth** _(Write)_: Specifies the file growth
increment of each tempdb data file in MB.
* **`[Boolean]` NpEnabled** _(Write)_: Specifies the state of the Named Pipes
protocol for the SQL Server service. The value $true will enable the Named
Pipes protocol and $false will disabled it.
* **`[Boolean]` TcpEnabled** _(Write)_: Specifies the state of the TCP protocol
for the SQL Server service. The value $true will enable the TCP protocol and
$false will disabled it.
* **`[UInt32]` SetupProcessTimeout** _(Write)_: The timeout, in seconds, to wait
for the setup process to finish. Default value is 7200 seconds (2 hours). If
the setup process does not finish before this time, and error will be thrown.
Expand Down
77 changes: 70 additions & 7 deletions source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,15 @@ function Get-TargetResource
.PARAMETER SqlTempdbLogFileGrowth
Specifies the file growth increment of each tempdb data file in MB.
.PARAMETER NpEnabled
Specifies the state of the Named Pipes protocol for the SQL Server service.
The value $true will enable the Named Pipes protocol and $false will disabled
it.
.PARAMETER TcpEnabled
Specifies the state of the TCP protocol for the SQL Server service. The
value $true will enable the TCP protocol and $false will disabled it.
.PARAMETER SetupProcessTimeout
The timeout, in seconds, to wait for the setup process to finish. Default
value is 7200 seconds (2 hours). If the setup process does not finish before
Expand Down Expand Up @@ -860,6 +869,14 @@ function Set-TargetResource
[System.UInt32]
$SqlTempdbLogFileGrowth,

[Parameter()]
[System.Boolean]
$NpEnabled,

[Parameter()]
[System.Boolean]
$TcpEnabled,

[Parameter()]
[System.UInt32]
$SetupProcessTimeout = 7200,
Expand Down Expand Up @@ -1246,6 +1263,30 @@ function Set-TargetResource
$setupArguments['SQLSysAdminAccounts'] += $SQLSysAdminAccounts
}

if ($PSBoundParameters.ContainsKey('NpEnabled'))
{
if ($NpEnabled)
{
$setupArguments['NPENABLED'] = 1
}
else
{
$setupArguments['NPENABLED'] = 0
}
}

if ($PSBoundParameters.ContainsKey('TcpEnabled'))
{
if ($TcpEnabled)
{
$setupArguments['TCPENABLED'] = 1
}
else
{
$setupArguments['TCPENABLED'] = 0
}
}

$argumentVars += @(
'SecurityMode',
'SQLCollation',
Expand Down Expand Up @@ -1418,18 +1459,14 @@ function Set-TargetResource
{
if ($argument -eq 'ProductKey')
{
$setupArguments += @{
'PID' = (Get-Variable -Name $argument -ValueOnly)
}
$setupArguments['PID'] = Get-Variable -Name $argument -ValueOnly
}
else
{
# If the argument contains a value, then add the argument to the setup argument list
if (Get-Variable -Name $argument -ValueOnly)
{
$setupArguments += @{
$argument = (Get-Variable -Name $argument -ValueOnly)
}
$setupArguments[$argument] = Get-Variable -Name $argument -ValueOnly
}
}
}
Expand All @@ -1438,7 +1475,12 @@ function Set-TargetResource
$arguments = ''
foreach ($currentSetupArgument in $setupArguments.GetEnumerator())
{
if ($currentSetupArgument.Value -ne '')
<#
Using [System.String]::IsNullOrEmpty() instead if comparing against
an empty string ('') because the numeric value zero (0) equals to an
empty string. This is evaluated to $true: 0 -eq ''
#>
if (-not [System.String]::IsNullOrEmpty($currentSetupArgument.Value))
{
# Arrays are handled specially
if ($currentSetupArgument.Value -is [System.Array])
Expand Down Expand Up @@ -1781,6 +1823,19 @@ function Set-TargetResource
.PARAMETER SqlTempdbLogFileGrowth
Specifies the file growth increment of each tempdb data file in MB.
.PARAMETER NpEnabled
Specifies the state of the Named Pipes protocol for the SQL Server service.
The value $true will enable the Named Pipes protocol and $false will disabled
it.
Not used in Test-TargetResource.
.PARAMETER TcpEnabled
Specifies the state of the TCP protocol for the SQL Server service. The
value $true will enable the TCP protocol and $false will disabled it.
Not used in Test-TargetResource.
.PARAMETER SetupProcessTimeout
The timeout, in seconds, to wait for the setup process to finish. Default
value is 7200 seconds (2 hours). If the setup process does not finish before
Expand Down Expand Up @@ -2027,6 +2082,14 @@ function Test-TargetResource
[System.UInt32]
$SqlTempdbLogFileGrowth,

[Parameter()]
[System.Boolean]
$NpEnabled,

[Parameter()]
[System.Boolean]
$TcpEnabled,

[Parameter()]
[System.UInt32]
$SetupProcessTimeout = 7200,
Expand Down
2 changes: 2 additions & 0 deletions source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.schema.mof
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class DSC_SqlSetup : OMI_BaseResource
[Write, Description("Specifies the file growth increment of each tempdb data file in MB.")] UInt32 SqlTempdbFileGrowth;
[Write, Description("Specifies the initial size of each tempdb log file in MB.")] UInt32 SqlTempdbLogFileSize;
[Write, Description("Specifies the file growth increment of each tempdb data file in MB.")] UInt32 SqlTempdbLogFileGrowth;
[Write, Description("Specifies the state of the Named Pipes protocol for the SQL Server service. The value $true will enable the Named Pipes protocol and $false will disabled it.")] Boolean NpEnabled;
[Write, Description("Specifies the state of the TCP protocol for the SQL Server service. The value $true will enable the TCP protocol and $false will disabled it.")] Boolean TcpEnabled;
[Write, Description("The timeout, in seconds, to wait for the setup process to finish. Default value is 7200 seconds (2 hours). If the setup process does not finish before this time, and error will be thrown.")] UInt32 SetupProcessTimeout;
[Write, Description("Feature flags are used to toggle functionality on or off. See the documentation for what additional functionality exist through a feature flag.")] String FeatureFlag[];
[Read, Description("Returns a boolean value of $true if the instance is clustered, otherwise it returns $false.")] Boolean IsClustered;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ Configuration Example
ASBackupDir = 'C:\MSOLAP\Backup'
ASTempDir = 'C:\MSOLAP\Temp'
SourcePath = 'C:\InstallMedia\SQL2016RTM'
NpEnabled = $true
TcpEnabled = $true
UpdateEnabled = 'False'
ForceReboot = $false

Expand Down
2 changes: 2 additions & 0 deletions tests/Integration/DSC_SqlSetup.config.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ Configuration DSC_SqlSetup_InstallDatabaseEngineNamedInstanceAsSystem_Config
SqlTempDbFileGrowth = $Node.SqlTempDbFileGrowth
SqlTempDbLogFileSize = $Node.SqlTempDbLogFileSize
SqlTempDbLogFileGrowth = $Node.SqlTempDbLogFileGrowth
NpEnabled = $true
TcpEnabled = $true

# This must be set if using SYSTEM account to install.
SQLSysAdminAccounts = @(
Expand Down
15 changes: 14 additions & 1 deletion tests/Integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ MSSQLSERVER | SQLENGINE,CONN,BC,SDK | - | Stopped

All running Database Engine instances also have a SQL Server Agent that is started.

The instance DSCSQLTEST support mixed authentication mode.
The instance DSCSQLTEST support mixed authentication mode, and will have
both Named Pipes and TCP/IP protocol enabled.

>**Note:** Some services are stopped to save memory on the build worker. See the
>column *State*.
Expand Down Expand Up @@ -381,3 +382,15 @@ ScriptDatabase4 | DscAdmin1

*The integration tests will clean up and not leave anything on the build
worker.*

## SqlServerProtocol

**Run order:** 6

**Depends on:** SqlSetup

Depends that the instance `DSCSQLTEST` have the Named Pipes protocol
enabled (SqlSetup is run with `NpEnabled = $true`).

*The integration tests will clean up and not leave anything on the build
worker.*
Loading

0 comments on commit 356c11a

Please sign in to comment.