dsccommunity / dsccommunity/SqlServerDsc

SqlWindowsFirewall: Specifying Absent doesn't remove the firewall rule

Open
#1,276 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug 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

Specifying a SqlWindowsFirewall resource with Ensure = Absent does not remove the firewall rules. It acts like the Test-DscResource returns $false but the Set-DscResource does not remove the rules. If you run it a second time it behaves the same.

Verbose logs showing the problem
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' =
root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer svr2 with user sid S-1-5-21-2127570298-2456136873-3738851636-1106.
VERBOSE: [Server1]: LCM:  [ Start  Set      ]
VERBOSE: [Server1]: LCM:  [ Start  Resource ]  [[SqlWindowsFirewall]RemoveFirewallRule]
VERBOSE: [Server1]: LCM:  [ Start  Test     ]  [[SqlWindowsFirewall]RemoveFirewallRule]
VERBOSE: [Server1]:                            [[SqlWindowsFirewall]RemoveFirewallRule] 2019-01-27_14-29-14: Using path: C:\Software\SQLServer2017\setup.exe
VERBOSE: [Server1]: LCM:  [ End    Test     ]  [[SqlWindowsFirewall]RemoveFirewallRule]  in 0.5940 seconds.
VERBOSE: [Server1]: LCM:  [ Start  Set      ]  [[SqlWindowsFirewall]RemoveFirewallRule]
VERBOSE: [Server1]:                            [[SqlWindowsFirewall]RemoveFirewallRule] 2019-01-27_14-29-15: Using path: C:\Software\SQLServer2017\setup.exe
VERBOSE: [Server1]:                            [[SqlWindowsFirewall]RemoveFirewallRule] 2019-01-27_14-29-15: Using path: C:\Software\SQLServer2017\setup.exe
VERBOSE: [Server1]:                            [[SqlWindowsFirewall]RemoveFirewallRule] 2019-01-27_14-29-15: Using path: C:\Software\SQLServer2017\setup.exe
VERBOSE: [Server1]: LCM:  [ End    Set      ]  [[SqlWindowsFirewall]RemoveFirewallRule]  in 1.2340 seconds.
VERBOSE: [Server1]: LCM:  [ End    Resource ]  [[SqlWindowsFirewall]RemoveFirewallRule]
VERBOSE: [Server1]: LCM:  [ End    Set      ]
VERBOSE: [Server1]: LCM:  [ End    Set      ]    in  1.9060 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 2.071 seconds
Suggested solution to the issue

Fix within the Set but I haven't looked into it yet.

The DSC configuration that is used to reproduce the issue (as detailed as possible)
Node 'server1' {
        SqlWindowsFirewall RemoveFirewallRule
        {
            Ensure = 'Absent'
            Features = 'SQLENGINE'
            InstanceName = 'MSSQLSERVER'
            SourcePath = 'C:\Software\SQLServer2017\'
        }
}
SQL Server edition and version the target node is running

SQL Server 2017

SQL Server PowerShell modules present on the target node

None

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

5.1.17763.1

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

12.2.0.0

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 by tracing the SqlWindowsFirewall resource's Set implementation using the provided Ensure = 'Absent' configuration and verbose log. Reproduce the issue on the stated Windows Server 2019 and SQL Server 2017 setup, then verify that applying the configuration removes the firewall rules and converges on subsequent runs.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
devops, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.