-
Notifications
You must be signed in to change notification settings - Fork 55
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
DnsServerDsc: Resources errors on test if DNS is not installed #45
Comments
@GoateePFE I'd be willing to add this functionality. I'm not sure how to best handle the error. |
@Persistent13 That should do it for now. Long term we should probably add a function to the root of the resource module to check for the presence of the DNS server role and warn if it is not installed. Then all resources could reference that. Function Test-DNSServerRole { Easy enough. |
I'm sure there's an Assert-Module function in the xActiveDirectory module that you can copy/duplicate!
|
Label this as help wanted to that someone in the community can run with this. |
https://github.com/PowerShell/xDnsServer/blob/dev/DSCResources/Helper.psm1 This Helper Module includes So just need to ensure that the others include and use it |
Assert-Module will still error out on Get if the module isn't installed. I think Assert-Module still needs to be added to all of the resources in xDnsServer. For not erroring out on Get we could do a try catch: try
{
Assert-Module -ModuleName 'DNS'
}
catch
{
Write-Warning -Message 'DNS module is not installed and this resource will not work properly.'
return @{
Ensure = 'Absent'
Prop = $null
}
} |
Actually since Get nor Set use any cmdlets from the DNS module we can just remove and |
Most of the resources in XDnsServer do require it. So I was thinking it needed to be added to those. This was specifically opened to not error out in Get, is that something we can support? |
Yes to both. For all the resource; Get-TargetResource should be able to return the result without throwing an error. It should always return the correct hashtable (all the properties in the schema), either with the actual current values or with null values for those properties it cannot fetch. Key properties should always be set to the configuration values and if there is an Ensure property it should be set to Absent if the Key values does not exist in the current state. |
Awesome. I will look at doing that. |
xDNSServerForwarder (as well as other resource in the module) need error handling logic to gracefully return FALSE on the Test function when DNS is not installed. This is particularly needed when DSC is used to audit a server config without applying.
The text was updated successfully, but these errors were encountered: