voxpupuli / puppet-windowsfeature

Library that uses ServerAdministration api that comes with Windows Server 2008 and Windows Server 2012 to add / remove windows features
https://forge.puppet.com/puppet/windowsfeature
MIT License
30 stars 50 forks source link

Source parameter throwing an error #80

Closed rychannel closed 7 years ago

rychannel commented 7 years ago

I specified a source parameter but I get an error like its not even being used. Trying to install .Net frameworks...

Error: /Stage[main]/Profiles::Iis/Windowsfeature[NET-Framework-Core]/ensure: change from absent to present failed: Execution of 'C:\Windows\system32\WindowsPowershell\v1.0\powershell.exe Install-WindowsFeature NET-Framework-Core' returned 1: Install-WindowsFeature : The request to add or remove features on the specified server failed. Installation of one or more roles, role services, or features failed. The source files could not be found. Use the "Source" option to specify the location of the files that are required to restore the feature. For more information on specifying a source location, see http://go.microsoft.com/fwlink/?LinkId=243077. Error: 0x800f081f At line:1 char:1

rychannel commented 7 years ago

This is on a default install of Windows Server 2016 (No gui)

azap1111 commented 7 years ago

I'm also seeing the same error as @rychannel on Server 2012R2 and Server 2016 with the GUI installed. I started receiving the source errors after upgrading the WindowsFeature module from 2.0.0 to 2.1.0.

cargiris commented 7 years ago

I've corrected this behavior locally after wrestling with the same installation for NET-Framework-Core, where the source was on an NFS share.

For the line here: https://github.com/voxpupuli/puppet-windowsfeature/blob/master/lib/puppet/provider/windowsfeature/default.rb#L77

I've changed it to: array << "-Source #{resource['source']}" if !@resource[:source].to_s.strip.empty?

This seems to have added the source parameter as you'd expect, which allowed me to install the NET-Framework-Core feature via the module with the source provided. I have yet to test this change, but under the "successful" case it works as expected.

azap1111 commented 7 years ago

That's great news. I'll give it another shot. Thanks @Spartanaco

cargiris commented 7 years ago

I noticed there are no spec tests in place for the -source or -restart parameters, I was considering extending the PR I opened to include a test for a valid -source parameter, but I will see what they want for an acceptable PR.

bbriggs commented 7 years ago

Hey @Spartanaco. Thanks for the PR in #81. As you mentioned, I'd be happy to see some tests added for that particular section.

bbriggs commented 7 years ago

This ~should be~ is resolved by #81