Closed Jonne closed 9 years ago
Hi @Jonne, glad you like it - let's make it better!
Are you able to send through a few details so I can take a look?
...and it could quite possibly be a bug.
Thanks!
Host = Windows 8.1, Guest = Windows 2102
Vagrant File:
Vagrant.configure(2) do |config| config.vm.box = "mwrock/Windows2012R2" config.vm.guest = :windows config.vm.network "forwarded_port", guest: 80, host: 8081, auto_correct: true config.vm.provision :shell, :path => "shell/InstallChocolatey.ps1"
config.vm.provision :dsc do |dsc| dsc.configuration_file = "powershell/Config.ps1" dsc.module_path = ["modules"] end end
FolderStructure:
powershell --Config.ps1 modules --CommonConfig (Contains a DSC composite resource) VagrantFile shell --InstallChocolatey.ps1
Thanks for that, let me see if I can improve the very basic setup in the 'development' folder to include modules. Unit tests cover this scenario but of course uses heavy I/O mocks to get the job done so there is probably a gap in there. I won't be able to spend much on this tonight but will look tomorrow (it sounds like you can continue with the workaround for now?).
For the work around I need to change the runner powershell script, so added a pull request. Don't know if you want to solve it like this, but this works for me
And would you happen to know if setting the PSModulePath should work with normal DSCResources? It works with my Composite Resource, but for some resource normal DSC resources don't work. I get:
The PowerShell provider ChocolateyDSC does not exist at the PowerShell module
Yeah apparently they need to be under program files:
Because LCM runs in System context, applying a configuration fails if your resources module are not in the $pshome or $env:ProgramFiles folder. The differences in the authoring experience are discussed in this post, in the Import-DSCResources section.
So maybe instead of mapping the modules paths as $env:PSModulePath, we should copy the contents to the program files\WIndowsPowershell\modules path?
Hmm, you shouldn't have to put the resources into a known/default path (such as $pshome
). Are you using Import-DSCResource
from within your composite resource? Provided the directory structure of your Module is set out correctly and its root folder is contained in one of the $env:PSModulePath
locations it should be able to resource.
Import-DscResource: Import-DScResource is a dynamic keyword which can only be used inside a Configuration script block. When you are authoring a new configuration, you must import the resources needed by your configuration using this cmdlet. But if your DSC resources are stored in $pshome, you don’t need to explicitly import them. They are automatically loaded by PowerShell.
Either way, let me hack away at something and put into the development folder. I noticed your PR, i'll confirm first and if that addresses the issue we can go from there.
Appreciate your help!
Thanks to PR https://github.com/mefellows/vagrant-dsc/pull/9 this issue is now closed.
First of all, thanks for this great plugin!
When I add a module folder, this path is added to the powershell module path: /tmp/vagrant-dsc-3/modules-0; and it cannot find the module.
If I change it to a valid Windows path: C:\tmp\vagrant-dsc-3\modules-0 it does work.
Am i using it wrong or is this a bug?