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

Win 2008 R2 seems to be having issues with ConvertTo-JSON #71

Closed jefrazie closed 7 years ago

jefrazie commented 7 years ago

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

if (versioncmp( $::kernelmajversion, '6.1') >= 0 ) {
  windowsfeature { 'NET-Framework-Core':
    ensure             => present,
    installsubfeatures => true,
    before             => File['C:/AutomatosRPC'],
  }

What are you seeing

If we need to install the .NET framework, the Puppet run fails stating it cannot find Get-WindowsFeature.

What behaviour did you expect instead

Get-WindowsFeature installs the .NET framework

Output log

Error: Failed to apply catalog: Execution of 'C:\Windows\system32\WindowsPowersh ell\v1.0\powershell.exe Get-WindowsFeature | ConvertTo-JSON' returned 1: The ter m 'Get-WindowsFeature' is not recognized as the name of a cmdlet, functi on, script file, or operable program. Check the spelling of the name, or if a p ath was included, verify that the path is correct and try again. At line:1 char:19

Any additional information you'd like to impart

matthewrstone commented 7 years ago

Pull request #58 should fix that, which I believe is in master since August but I'm not sure a new version of the module ever made it to the forge. Are you able to test with the version in the master branch to see if that resolved the issue? If so we just need to press wherever/whomever for a release.

james-powis commented 7 years ago

@matthewrstone I commented in the PR but I am not seeing 2008R2 as being useable, self.instances is throwing REXML errors:

PS C:\Program Files\Puppet Labs\Puppet\sys\ruby\bin> puppet resource windowsfeature --debug --verbose --trace
Debug: Runtime environment: puppet_version=4.5.2, ruby_version=2.1.8, run_mode=user, default_encoding=IBM437
Debug: Facter: searching for custom fact "kernel".
Debug: Facter: searching for kernel.rb in C:/ProgramData\PuppetLabs\puppet\cache\lib\facter.
Debug: Facter: searching for kernel.rb in C:/ProgramData\PuppetLabs\puppet\cache\lib\facter.
Debug: Facter: fact "facterversion" has resolved to "3.2.0".
Debug: Facter: initializing WMI
Debug: Facter: searching "C:\ProgramData\PuppetLabs\facter\facts.d" for external facts.
Debug: Facter: no external facts were found.
Debug: Facter: setting fact "env_windows_installdir" based on the value of environment variable "FACTER_env_windows_inst
alldir".
Debug: Facter: fact "env_windows_installdir" has resolved to "C:\Program Files\Puppet Labs\Puppet".
Debug: Facter: resolving kernel facts.
Debug: Facter: fact "kernel" has resolved to "windows".
Debug: Facter: fact "kernelrelease" has resolved to "6.1.7601".
Debug: Facter: fact "kernelmajversion" has resolved to "6.1".
Debug: Facter: fact "kernelversion" has resolved to "6.1.7601".
Debug: Facter: searching for custom fact "kernelmajversion".
Debug: Facter: searching for kernelmajversion.rb in C:/ProgramData\PuppetLabs\puppet\cache\lib\facter.
Debug: Facter: searching for kernelmajversion.rb in C:/ProgramData\PuppetLabs\puppet\cache\lib\facter.
Debug: Executing: 'C:\Windows\system32\WindowsPowershell\v1.0\powershell.exe Import-Module ServerManager; Get-WindowsFea
ture | ConvertTo-XML -As String -Depth 4 -NoTypeInformation'
Error: Could not run: malformed XML: missing tag start
Line: 4808
Position: 199234
Last 80 unconsumed characters:
< /Property>     <Property Name="Depth">3</Property>     <Property Name="DependsO
C:/Program Files/Puppet Labs/Puppet/sys/ruby/lib/ruby/2.1.0/rexml/parsers/baseparser.rb:374:in `pull_event'
C:/Program Files/Puppet Labs/Puppet/sys/ruby/lib/ruby/2.1.0/rexml/parsers/baseparser.rb:184:in `pull'
C:/Program Files/Puppet Labs/Puppet/sys/ruby/lib/ruby/2.1.0/rexml/parsers/treeparser.rb:22:in `parse'
C:/Program Files/Puppet Labs/Puppet/sys/ruby/lib/ruby/2.1.0/rexml/document.rb:287:in `build'
C:/Program Files/Puppet Labs/Puppet/sys/ruby/lib/ruby/2.1.0/rexml/document.rb:44:in `initialize'
C:/ProgramData/PuppetLabs/puppet/cache/lib/puppet/provider/windowsfeature/default.rb:32:in `new'
C:/ProgramData/PuppetLabs/puppet/cache/lib/puppet/provider/windowsfeature/default.rb:32:in `instances'
C:/Program Files/Puppet Labs/Puppet/puppet/lib/puppet/type.rb:1168:in `block in instances'
C:/Program Files/Puppet Labs/Puppet/puppet/lib/puppet/type.rb:1161:in `collect'
C:/Program Files/Puppet Labs/Puppet/puppet/lib/puppet/type.rb:1161:in `instances'
C:/Program Files/Puppet Labs/Puppet/puppet/lib/puppet/indirector/resource/ral.rb:24:in `search'
C:/Program Files/Puppet Labs/Puppet/puppet/lib/puppet/indirector/indirection.rb:269:in `search'
C:/Program Files/Puppet Labs/Puppet/puppet/lib/puppet/application/resource.rb:221:in `find_or_save_resources'
C:/Program Files/Puppet Labs/Puppet/puppet/lib/puppet/application/resource.rb:136:in `main'
C:/Program Files/Puppet Labs/Puppet/puppet/lib/puppet/application.rb:352:in `run_command'
C:/Program Files/Puppet Labs/Puppet/puppet/lib/puppet/application.rb:344:in `block in run'
C:/Program Files/Puppet Labs/Puppet/puppet/lib/puppet/util.rb:540:in `exit_on_fail'
C:/Program Files/Puppet Labs/Puppet/puppet/lib/puppet/application.rb:344:in `run'
C:/Program Files/Puppet Labs/Puppet/puppet/lib/puppet/util/command_line.rb:128:in `run'
C:/Program Files/Puppet Labs/Puppet/puppet/lib/puppet/util/command_line.rb:72:in `execute'
C:/Program Files/Puppet Labs/Puppet/puppet/bin/puppet:5:in `<main>'
james-powis commented 7 years ago

however the issue bing described in this issue was alleviated by pinning to the HEAD of the repo as it is today...

cdenneen commented 7 years ago

@matthewrstone @igalic @petems still seeing this error with latest tagged release

  Error: Failed to apply catalog: malformed XML: missing tag start
  Line: 4806
  Position: 193094
  Last 80 unconsumed characters:
  < /Property>     <Property Name="Depth">3</Property>     <Property Name="DependsO
rymurph20 commented 7 years ago

Seeing similar issues to @cdenneen

Error: Failed to apply catalog: Missing end tag for 'Property' (got "Object") Line: 1072 Position: 46435 Last 80 unconsumed characters:

josefprado commented 7 years ago

@cdenneen I´m facing the same issue here while trying to install a windows feature like "Telnet". It seems not work well in Windows 2008 R2.

Did you had any update on this issue elsewere?

Regards,

Josef

igalic commented 7 years ago

i think it's time we added a Windows testing environment to our windows modules

TraGicCode commented 7 years ago

I'm going to verify this

TraGicCode commented 7 years ago

Work's fine on the latest release when running beaker. Closing this.

image