A fix for Lability ‘Datafile not found’ error

Issue

I have been busy automating the provision of our private Azure DevOps Agents using Packer and Lability; a more details blog post is on the way. All has been going OK on my test rig, but when came to run the automation pipeline on our main build HyperV host I got an error


> Get-VmcConfigurationData : Datafile Environments\BuildAgent-VS2017\BuildAgent-VS2017.psd1 NOT FOUND. Exiting

But the file was there!

I check the default Lability  paths, but all these looked OK, and none pointed to my environment location on C: anyway

> Get-LabHostDefault



ConfigurationPath : D:\Virtualisation\Configuration
DifferencingBVhdPath : D:\Virtualisation\VMVirtualHardDisks
HotfixPath  : D:\Virtualisation\Hotfix
IsoPath : D:\Virtualisation\ISOs
ModuleCachePath : D:\Virtualisation\Modules
ParentVhdPath  : D:\Virtualisation\MasterVirtualHardDisks
RepositoryUri :
https://server/nuget/PowerShell/package

ResourcePath : D:\Virtualisation\Resources
ResourceShareName : Resources
DisableLocalFileCaching : False
DisableSwitchEnvironmentName : True
EnableCallStackLogging  : False
DismPath  : C:\Windows\System32\WindowsPowerShell\v1.0\Modules\Dism\Microsoft.Dism.PowerShell.dll

Solution

After a bit of digging in the lability PSM files I found the problem was the call

> Get-PSFConfigValue -Fullname “VMConfig.VMConfigsPath”

This returned nothing. A check on my development system showed this should return C:\VmConfigs, so I had a broken Lability install

So I tried the obvious fix, which was to set the missing value

> Set-PSFConfig -FullName “VMConfig.VMConfigsPath” -Value c:\VmConfigs

And it worked, my Lability installs ran without a problem