dsccommunity / SqlServerDsc

This module contains DSC resources for deployment and configuration of Microsoft SQL Server.
MIT License
359 stars 224 forks source link

SqlSetup: SQL Server 2016 update failed #1418

Closed quanglegl1404 closed 4 years ago

quanglegl1404 commented 5 years ago

Details of the scenario you tried and the problem that is occurring

I'm trying to use SqlSetup resource to install SQL Server 2016 SP2 on virtual machine. I have a folder with SQL Server 2016 SP1 installation files and one sub folder storing executable file for SQL Server 2016 SP2. I used paremeters UpdateEnabled and UpdateSource. But there was error which failed to execute Set-TargetResource.

Verbose logs showing the problem

image DscExtensionHandler.0.20190808-153727.log

Suggested solution to the issue

N/A

The DSC configuration that is used to reproduce the issue (as detailed as possible)

# insert configuration here
Configuration d365_03_test {

param([String]
    $SQLServer2016SP2_dbFeatures = 'SQLENGINE,FULLTEXT, RS',[String]
    $SQLServer2016SP2_dbVersion = '2016\SQL2016-x64-ENU',[String]
    $SQLServer2016SP2_dbInstanceName = 'MSSQLDATABASE',[String]
    $SQLServer2016SP2_sqlServerPassword,[String]
    $SQLServer2016SP2_AddFirewallRule8080 = 'Present',[String]
    $SQLServer2016SP2_AddFirewallRule1433 = 'Present',[String]
    $SQLServer2016SP2_AddFirewallRule1434 = 'Present',[String])

Import-DscResource -ModuleName PSDesiredStateConfiguration
Import-DscResource -ModuleName SqlServerDsc
Import-DscResource -ModuleName NetworkingDsc

Node localhost {

$installationDrivePS_DriveLetter = "X"

Script InstallationDrive{
    SetScript = {
        $securePassword = ConvertTo-SecureString $using:InstallationDrive_shareDrivePassword -AsPlainText -Force
        $credential = New-Object System.Management.Automation.PSCredential ($using:InstallationDrive_shareDriveUser, $securePassword)
        New-PSDrive -Name $using:installationDrivePS_DriveLetter -Root $using:InstallationDrive_shareDriveAddress -Persist -PSProvider "FileSystem" -Scope Global -Credential $credential
    }
    TestScript = {
        Test-Path "$($using:installationDrivePS_DriveLetter):\"
    }
    GetScript = {
        @{ Result = "$($using:installationDrivePS_DriveLetter):" }
    }
}

$databaseInstallationPath = 'C:\Installation\Database'
$sharedDriveInstallLocation = 'X:\SQL_Server'

WindowsFeature 'SQL_NetFramework35'
{
    Name   = 'NET-Framework-Core'
    Source = '\\fileserver.company.local\images$\Win2k12R2\Sources\Sxs' # Assumes built-in Everyone has read permission to the share and path.
    Ensure = 'Present'
}

WindowsFeature 'SQL_NetFramework45'
{
    Name   = 'NET-Framework-45-Core'
    Ensure = 'Present'
}

Firewall AddFirewallRule8080
        {
            Name                  = 'Open port 8080'
            DisplayName           = 'Open port 8080'
            Ensure                = $SQLServer2016SP2_AddFirewallRule8080
            Enabled               = 'True'
            Profile               = ('Domain', 'Private', 'Public')
            Direction             = 'InBound'
            LocalPort             = ('8080')
            Protocol              = 'TCP'
            Description           = 'Open port 8080'
        }

Firewall AddFirewallRule1433
        {
            Name                  = 'SQL open port 1433'
            DisplayName           = 'SQL open port 1433'
            Ensure                = $SQLServer2016SP2_AddFirewallRule1433
            Enabled               = 'True'
            Profile               = ('Domain', 'Private', 'Public')
            Direction             = 'InBound'
            LocalPort             = ('1433')
            Protocol              = 'TCP'
            Description           = 'Open port 1433'
        }

Firewall AddFirewallRule1434
        {
            Name                  = 'SQL open port 1434'
            DisplayName           = 'SQL open port 1434'
            Ensure                = $SQLServer2016SP2_AddFirewallRule1434
            Enabled               = 'True'
            Profile               = ('Domain', 'Private', 'Public')
            Direction             = 'InBound'
            LocalPort             = ('1434')
            Protocol              = 'UDP'
            Description           = 'Open port 1434'
        }

File CopySQLServer
{
    Ensure = "Present"
    Type = "Directory"
    Recurse = $true #
    SourcePath = "$sharedDriveInstallLocation\$SQLServer2016SP2_dbVersion"
    DestinationPath = $databaseInstallationPath
}

if ([string]::IsNullOrEmpty($SQLServer2016SP2_sqlServerPassword))
{
    $SQLServer2016SP2_sqlServerPassword = $global_Password
}
$securePassword = ConvertTo-SecureString $SQLServer2016SP2_sqlServerPassword -AsPlainText -Force

SqlSetup 'InstallDefaultDBInstance'
{
    InstanceName        = $SQLServer2016SP2_dbInstanceName
    Features            = $SQLServer2016SP2_dbFeatures
    SQLSysAdminAccounts = @('Administrators')
    DependsOn           = '[WindowsFeature]SQL_NetFramework45','[File]CopySQLServer'
    SourcePath          = $databaseInstallationPath
    AgtSvcAccount       = New-Object System.Management.Automation.PSCredential ('NT Service\SQLAgent$MSSQLDATABASE', $securePassword)
    RsSvcStartupType    = 'Automatic'
    UpdateEnabled       = 'True'
   UpdateSource         = '.\SQL2016-SP2'
}

SqlServerNetwork 'ChangeTcpIpOnDefaultInstance'
{
            InstanceName         = $SQLServer2016SP2_dbInstanceName
            ProtocolName         = 'Tcp'
            IsEnabled            = $true
            TCPDynamicPort       = $false
            TCPPort              = 1433
            RestartService       = $true
            DependsOn            = '[SqlSetup]InstallDefaultDBInstance'
}

Script UnmountInstallationDrive{
    SetScript = {
        $UnmountInstallationDrive_DriveLetter = "X"

        Remove-PSDrive -Name "${UnmountInstallationDrive_DriveLetter}"
    }
    TestScript = {
        $UnmountInstallationDrive_DriveLetter = "X"

        !(Test-Path "${UnmountInstallationDrive_DriveLetter}:")
    }
    GetScript = {
        $UnmountInstallationDrive_DriveLetter = "X"

        @{ Result = !(Test-Path "${UnmountInstallationDrive_DriveLetter}:")}
    }
}
LocalConfigurationManager {
 ActionAfterReboot = 'ContinueConfiguration' 
 RebootNodeIfNeeded = $true
}}
}

SQL Server edition and version the target node is running

SQL Server Enterprise 2016. Version: SP1 => Update to SP2

SQL Server PowerShell modules present on the target node

N/A

The operating system the target node is running

OsName : Microsoft Windows Server 2019 Datacenter OsOperatingSystemSKU : DatacenterServerEdition OsArchitecture : 64-bit WindowsVersion : 1809 WindowsBuildLabEx : 17763.1.amd64fre.rs5_release.180914-1434 OsLanguage : en-US OsMuiLanguages : {en-US}

Version and build of PowerShell the target node is running

Name Value


PSVersion 5.1.17763.592 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.17763.592 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

Version of the DSC module that was used ('dev' if using current dev branch)

12.5.0.0 C:\Program Files\WindowsPowerShell\Modules\SqlServerDsc\12.5.0.0\SqlServerDsc.psd1

johlju commented 5 years ago

Please check what the setup.exe reported for errors in the logs. See https://docs.microsoft.com/en-us/sql/database-engine/install-windows/view-and-read-sql-server-setup-log-files for help.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had activity from the community in the last 30 days. It will be closed if no further activity occurs within 10 days. If the issue is labelled with any of the work labels (e.g bug, enhancement, documentation, or tests) then the issue will not auto-close.

stale[bot] commented 4 years ago

This issue has been automatically closed because it is has not had activity from the community in the last 40 days.