Skip to content

Commit 8467b66

Browse files
committed
(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.
1 parent 3f9f9e8 commit 8467b66

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb

+2-4
Original file line numberDiff line numberDiff line change
@@ -656,8 +656,8 @@ def interpolate_variables(string)
656656
modified_string
657657
end
658658

659-
# Parses a resource definition (as from `invocable_resource`) and, if the resource is implemented
660-
# as a PowerShell class, ensures the System environment variable for PSModulePath is munged to
659+
# Parses a resource definition (as from `invocable_resource`) and
660+
# ensures the System environment variable for PSModulePath is munged to
661661
# include the vendored PowerShell modules. Due to a bug in PSDesiredStateConfiguration, class-based
662662
# DSC Resources cannot be called via Invoke-DscResource by path, only by module name, *and* the
663663
# module must be discoverable in the system-level PSModulePath. The postscript for invocation has
@@ -666,8 +666,6 @@ def interpolate_variables(string)
666666
# @param resource [Hash] a hash with the information needed to run `Invoke-DscResource`
667667
# @return [String] A multi-line string which sets the PSModulePath at the system level
668668
def munge_psmodulepath(resource)
669-
return unless resource[:dscmeta_resource_implementation] == 'Class'
670-
671669
vendor_path = resource[:vendored_modules_path].tr('/', '\\')
672670
<<~MUNGE_PSMODULEPATH.strip
673671
$UnmungedPSModulePath = [System.Environment]::GetEnvironmentVariable('PSModulePath','machine')

0 commit comments

Comments
 (0)