From 8467b66bcda5f1f355487f00dbcd0dbba5de8773 Mon Sep 17 00:00:00 2001 From: jordanbreen28 Date: Tue, 12 Dec 2023 15:01:45 +0000 Subject: [PATCH] (CAT-1617) - Always load vendored module in PSModulePath Prior to this commit, the vendored dsc module would only be loading into the PSModulePath Env variable if the dsc resource type was implemented as a Class. Now that DSC Modules seem to be taking the approach of abstracting the DscResource.Base module into a seperate module which is then imported, we need to alter the PSModulePath Env variable to include the vendored modules path to ensure these modules are imported as expected. --- lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb b/lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb index 6bc42ffe..d6709dd3 100644 --- a/lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb +++ b/lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb @@ -656,8 +656,8 @@ def interpolate_variables(string) modified_string end - # Parses a resource definition (as from `invocable_resource`) and, if the resource is implemented - # as a PowerShell class, ensures the System environment variable for PSModulePath is munged to + # Parses a resource definition (as from `invocable_resource`) and + # ensures the System environment variable for PSModulePath is munged to # include the vendored PowerShell modules. Due to a bug in PSDesiredStateConfiguration, class-based # DSC Resources cannot be called via Invoke-DscResource by path, only by module name, *and* the # module must be discoverable in the system-level PSModulePath. The postscript for invocation has @@ -666,8 +666,6 @@ def interpolate_variables(string) # @param resource [Hash] a hash with the information needed to run `Invoke-DscResource` # @return [String] A multi-line string which sets the PSModulePath at the system level def munge_psmodulepath(resource) - return unless resource[:dscmeta_resource_implementation] == 'Class' - vendor_path = resource[:vendored_modules_path].tr('/', '\\') <<~MUNGE_PSMODULEPATH.strip $UnmungedPSModulePath = [System.Environment]::GetEnvironmentVariable('PSModulePath','machine')