dsccommunity / dsccommunity/SqlServerDsc

SqlAlwaysOnService: Permission requirement need to be updated

Open
#808 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
PowerShell
Stars
385
Forks
224
PR merge metrics
No merged PRs in 30d

Description

Details of the scenario you tried and the problem that is occurring:
When enabling AlwaysOn it is sufficient with local administrator permission. But the resource will fail if that account does not also have permission to read the IsHadrEnable property of the SQL Server (Database Engine) object.
It must also have the permission to read the IsClustered property.

Error:

VERBOSE: [APPVYR-WIN]:                            [[xSQLServerAlwaysOnService]Integration_Test] Getting SQL Server service information.
Cannot find any service with display name 'SQL Server ()'.
    + CategoryInfo          : ObjectNotFound: (SQL Server ():) [], CimException
    + FullyQualifiedErrorId : NoServiceFoundForGivenDisplayName,Microsoft.PowerShell.Commands.GetServiceCommand
    + PSComputerName        : localhost

Note: This error will change with PR #799, to correctly throw an error if it cannot read that the Database Engine has the online state.

I was scratching my head why this did not work. It did enable AlwaysOn, but failed to restart the service.

The DSC configuration that is using the resource (as detailed as possible):

        xSQLServerAlwaysOnService 'Integration_Test'
        {
            Ensure               = 'Present'
            SQLServer            = $Node.ComputerName
            SQLInstanceName      = $Node.InstanceName
            RestartTimeout       = $Node.RestartTimeout

            PsDscRunAsCredential = $SqlInstallCredential # <--- This account was only local administrator.

            DependsOn            = @(
                '[WindowsFeature]AddFeatureFailoverClustering'
                '[WindowsFeature]AddFeatureFailoverClusteringPowerShellModule'
                '[Script]CreateActiveDirectoryDetachedCluster'
            )
        }

Version of the Operating System, SQL Server and PowerShell the DSC Target Node is running:
Windows Server 2016, SQL Server 2016, WMF 5.1

What module (SqlServer or SQLPS) and which version of the module the DSC Target Node is running:
SQLPS

Version of the DSC module you're using, or 'dev' if you're using current dev branch:
Dev

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the xSQLServerAlwaysOnService resource and review PR #799, then reproduce the Windows Server 2016 and SQL Server 2016 scenario using the local-administrator credential shown. Confirm the required permissions for IsHadrEnable and IsClustered and the resulting service-restart behavior; done means the resource reports the missing access clearly and handles the configuration consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, sql
Domain
databases, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.