dsccommunity / dsccommunity/SqlServerDsc
SqlLogin: Got message "Failed to invoke DSC Test method: An internal error occurred" when user disabled
Nobody has claimed this yet.
- 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
I'm using ansible with win_dsc module to create an user
- name: Create user
win_dsc:
resource_name: SqlLogin
Ensure: "{% if db_state == 'absent' %}Absent{% else %}Present{% endif %}"
Name: "{{ db_user }}"
LoginType: SqlLogin
ServerName: "localhost"
InstanceName: "MSSQLSERVER"
LoginCredential_username: "{{ db_user }}"
LoginCredential_password: "{{ db_password }}"
LoginMustChangePassword: false
LoginPasswordExpirationEnabled: false
LoginPasswordPolicyEnforced: false
Disabled: "{% if db_state == 'disabled' %}True{% else %}False{% endif %}"
register: mssql_create_user
when: install_psmodule_dbsrv is succeeded and mssql_service.state == 'running'
If user doesn't exist before, task runs successfully
But if user has exist and disabled, task failed with an error message: Failed to invoke DSC Test method: An internal error occurred.
Verbose logs showing the problem
TASK [create_user : MSSQL: Create user] **************************************************************************************************************************************************************************************************************
fatal: [mssqlserver.com]: FAILED! => {
"changed": false,
"module_version": "14.2.1",
"reboot_required": false
}
MSG:
Failed to invoke DSC Test method: An internal error occurred.
Suggested solution to the issue
I enabled this user then re-run ansible, task ran successfully
Maybe we need check if user has been disabled first
SQL Server edition and version the target node is running
Microsoft SQL Server 2016 (RTM) - 13.0.1601.5 (X64) Apr 29 2016 23:23:58 Copyright (c) Microsoft Corporation Enterprise Evaluation Edition (64-bit) on Windows Server 2016 Standard 6.3 (Build 14393: ) (Hypervisor)
SQL Server PowerShell modules present on the target node
PS C:\Users\Administrator> Get-Module -Name 'sql' -ListAvailable | ? Name -ne 'SqlServerDsc' | ft Name,Version,Path
Name Version Path
SQLPS 1.0 C:\Program Files (x86)\Microsoft SQL Server\130\Tools\PowerShell\Modules\SQLPS\SQLPS.psd1
The operating system the target node is running
OsName : Microsoft Windows Server 2016 Standard
OsOperatingSystemSKU : StandardServerEdition
OsArchitecture : 64-bit
WindowsBuildLabEx : 14393.2580.amd64fre.rs1_release_inmarket.181009-1745
OsLanguage : en-US
OsMuiLanguages : {en-US}
Version and build of PowerShell the target node is running
PS C:\Users\Administrator> $PSVersionTable
Name Value
PSVersion 5.1.14393.2580
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.2580
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Version of the DSC module that was used
PS C:\Users\Administrator> Get-Module -Name 'SqlServerDsc' -ListAvailable | ft Name,Version,Path
Name Version Path
SqlServerDsc 14.2.1 C:\Program Files\WindowsPowerShell\Modules\SqlServerDsc\14.2.1\SqlServerDsc.psd1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure through Ansible's win_dsc entry point using the SqlLogin resource with an existing disabled user. Inspect the SqlLogin DSC Test behavior and compare it with the successful create and enabled-user cases; done means an existing disabled login can be evaluated or converged without the internal-error message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ansible, powershell, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100