-
Notifications
You must be signed in to change notification settings - Fork 177
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
win_dsc: DSC Resources that specify 'System.ServiceProcess' as one of the 'RequiredAssemblies' are not discoverable using Get-DSCResource when run via Ansible #66
Comments
Do you have an example DSC resource that we can test with? The particular check where this is failing is very early on in the module and the only real call that happens is the If you can provide an example resource I can try I'm happy to try and replicate the error and find a fix. |
Files to reproduce the problem and the corresponding playbook code are detailed above. |
I downloaded your example resource and I can replicate the error. The issue is because the This isn't necessarily a problem with win_dsc but how PowerShell loads assemblies and how classes are parsed. There's a longstanding issue for this PowerShell/PowerShell#2074 that details what exactly is going on. You can even replicate this problem outside of Ansible by running As for the fix, I don't think we can really manage a list of assemblies that we are manually load as that would become quite unwieldy to maintain. I'm trying to see if there are any other options we can go with here, one potential one referenced in that issue is to load the class as a separate file but I'm seeing if there are other options. |
Could you try out the changes in #67. I'm weirdly unable to replicate the error you have when running it through the module but this fixes the problem I have when loading it directly on the console. |
If I add just the additions you made in #67 to the If I use the contents of the file #67 and remove the changes you made, then it also produces the The main difference between the version of |
Yea that's the weirdness I found, in any case it doesn't hurt to have, will merge it in for the next release. |
SUMMARY
If a custom DSC Resource contains a reference to System.ServiceProcess as one of the
RequiredAssemblies
in the respective.psd1
file, and the associated.psm1
file contains references to that assembly, the call toGet-DscResource
inwin_dsc
, when run via the Ansible, cannot find that DSC Resource (even though it does exist) and the Ansible call fails.ISSUE TYPE
COMPONENT NAME
win_dsc
ANSIBLE VERSION
CONFIGURATION
DISPLAY_SKIPPED_HOSTS(env: ANSIBLE_DISPLAY_SKIPPED_HOSTS) = False
OS / ENVIRONMENT
Windows 10
STEPS TO REPRODUCE
Unzip these files (ExampleDscResource.zip) to
C:\Program Files\WindowsPowerShell\Modules\ExampleDscResource\1.0.0.0
:Run
Get-DscResource
to confirm the DSC Resource is installed correctlyCreate a playbook containing the following:
EXPECTED RESULTS
The DSC Resource runs:
ACTUAL RESULTS
Adding
Add-Type -assemblyname System.ServiceProcess
towin_dsc
at the line preceding the call toGet-DscResource
here causes the playbook to execute successfully.The text was updated successfully, but these errors were encountered: