-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SqlSetup fails to run after configuring ForcedEncryption in SqlSecureConnection #1893
Comments
This get the information on current node on macOS so it might work on all OS'es, although it doesn't return FQDN there, but it is not connected to an AD domain either, so not a good example. 🙂
I think But it would not help if the network name to connect to is different than the hostname. For example when using AG or failover clustering. For failover clustering there is the parameter |
Seems [System.Net.Dns]::GetHostEntry('') |
I'm not currently running an AG in the configuration I'm testing with and that is something I hadn't yet thought about. I did consider proposing a FQDN switch for the I guess I should switch over to using I did consider that the DNS lookup could fail. I didn't have a better option when I started testing. This would also require the SQL server to have a network connection and a reachable DNS server (assuming that's how |
I think safest bet is to add |
- SqlSetup - Added new parameter `ServerName` that will be used as the host name when evaluating the SQL Server instance. If using a secure connection the specified value should be the same name that is used in the certificate (issue #1893).
@Kreby I merged the suggested fix. If there are any issue or if it doesn't work out as expected let me know and we make a change before next full release is released. |
@johlju Thanks for the turn around on that. The newly released |
@johlju I was able to test it this morning and verify that everything was working as expected now. Subsequent runs are no longer failing. I did it before you released the latest Thanks again for the help. |
Yes I went ahead and released the new version so we would get the support for SqlServer 22.0.59. Happy it worked as expected though, thanks for testing and reporting back. Then we squashed that one too. 😃 |
Problem description
The
SqlSetup
resource fails to execute on subsequent runs after an initial install if aSqlSecureConnection
resource has been processed and hasForceEncryption = $true
. The issue is related to the lack of support for FQDN's, much like in #1888.This specifics of this issue is two fold
Firstly the
ServerName
property forSqlSetup
is assumed and obtained using theGet-ComputerName
function. This only becomes a problem after Encryption is forced.Secondly, the root of the first issue, is the function
Get-ComputerName
from theDscResource.Common
module will only ever provide a hostname and is not capable of returning a FQDN.The
ServerName
variable is then passed to a number of other cmdlets which in turn callConnect-Sql
and we've seen before in, #1888, the use of a FQDN is required in order to connect.Verbose logs
DSC configuration
It's not really relevant to the issue but can provide if needed.
Suggested solution
The best option would probably be to add a
ServerName
property to theSqlSetup
resource which defaults to just using theGet-ComputerName
it is already assuming when the argument isn't supplied.If adding a
ServerName
property is not acceptable then trying to resolve the hostname via DNS is an option but I feel that might be more problematic. I too was using$env:COMPUTERNAME
previously but currently I am working around that by relying on DNSI do plan to go back to fix to pass the FQDN around but I haven't done that work yet.
I am currently only testing the DNS lookup on Server 2022 so I can't speak to it's support on other OS's as well older versions of Windows or PowerShell at the moment. I've not looked up to see what versions of Dot Net use this.
SQL Server edition and version
SQL Server PowerShell modules
Operating system
PowerShell version
SqlServerDsc version
The text was updated successfully, but these errors were encountered: