NetworkingDsc
NetworkingDsc copied to clipboard
xHostsFile: won't let me have identical hostnames with different adresses
Details of the scenario you tried and the problem that is occurring: The DSC configuration that is using the resource (as detailed as possible): Hi
I am trying to run this:
xHostsFile pool01
{
HostName = 'sfbpool1.domain.com'
IPAddress = '10.0.5.210'
Ensure = 'Present'
}
xHostsFile pool02
{
HostName = 'sfbpool1.domain.com'
IPAddress = '10.0.5.211'
Ensure = 'Present'
}
Meant to simulate round robin DNS. But xHostsFile fails with this message:
Test-ConflictingResources : A conflict was detected between resources '[xHostsFile]pool01 (C:\Script\dsc\SkypeForBusinessDSC.ps1::292::9::xHostsFile)' and '[xHostsFile]pool02 (C:\Script\dsc\SkypeForBusinessDSC.ps1::299::9::xHostsFile)' in node 'Edge01.domain.com'. Resources have identical key properties but there are differences in the following non-key properties: 'IPAddress'. Values '10.0.5.210' don't match values '10.0.5.211'. Please update these property values so that they are identical in both cases.
Version of the Operating System and PowerShell the DSC Target Node is running: Windows Server 2016 Standard 1607
Version of the DSC module you're using, or 'dev' if you're using current dev branch: 5.4.0.0
Hi There @tomlarse - this is actually by design. This wasn't a use case the resource was designed for. The resource needs a key property and the HostName was chosen for that purpose. I didn't actually realize round robin could be implemented with Hosts file (I'm not saying it can't - I just didn't know that :grin:).
One possible solution to this (and I'm not saying it could be easily implemented in the resource - because it would have challenges) would be to enable the IPAddress
to be an array. E.g.
xHostsFile pool01
{
HostName = 'sfbpool1.domain.com'
IPAddress = '10.0.5.210','10.0.5.211'
Ensure = 'Present'
}
This could probably be done but would require a significant change to the resource. I'll set this issue as help wanted and see if someone can pick it up?
Hi @PlagueHO if there are no takers I have an idea on how to implement it. ConvertFrom-String sprung to mind, but it will nevertheless require some modifications to the resource. It would improve readability though.