Closed oraziobattaglia closed 7 years ago
USING: Windows 2008 R2 Puppet 4.10 Puppet Server 2.1.2 (on CentOS 7) Ruby 2.1.9 (on Windows)
I and my job mate have the same problem and we change the ruby code default.rb to fix that issue:
Original Code:
# if win2008 import ServerManager module
result = if win2008 == true
ps('Import-Module ServerManager; Get-WindowsFeature | ConvertTo-XML -As String -Depth 4 -NoTypeInformation')
else
ps('Get-WindowsFeature | ConvertTo-XML -As String -Depth 4 -NoTypeInformation')
end
# create the XML document and parse the objects
xml = Document.new result
Changed code:
# if win2008 import ServerManager module
result = if win2008 == true
ps('Import-Module ServerManager; Get-WindowsFeature | ConvertTo-XML -As String -Depth 4 -NoTypeInformation > C:/ProgramData/PuppetLabs/puppet/cache/lib/puppet/provider/windowsfeature/result.xml')
else
ps('Get-WindowsFeature | ConvertTo-XML -As String -Depth 4 -NoTypeInformation > C:/ProgramData/PuppetLabs/puppet/cache/lib/puppet/provider/windowsfeature/result.xml')
end
file = File.new "C:/ProgramData/PuppetLabs/puppet/cache/lib/puppet/provider/windowsfeature/result.xml"
# create the XML document and parse the objects
xml = Document.new file
Ps.: We dont know much of ruby, but we think when powershell gives the result to the string, it makes something odd... Using file, we preserve the output xml; You can put the file result.xml in another place
This issue looks pretty easy to reproduce as the XML response from Get-WindowsFeature
returns invalid XML from File Services
object. The issue can be seen when installing any feature on Windows 2008R2 since the ConvertTo-XML
does not return a valid XML document.
<Property Name="Value"><!-- Copyright (c) Microsoft Corporation. All rights reserved. --><ViewerConfig><QueryConfig><QueryParams><UserQuery /></QueryParams><QueryNode><Name ResourceId="%windir%\system32\svrmgrnc.dll,-412">File Server</Name><Description ResourceId="%windir%\system32\svrmgrnc.dll,-413">System events for File Server</Description><SuppressQueryExecutionErrors>1</SuppressQueryExecutionErrors><QueryList><Query><!-- FS Role optional components BEGIN --><!-- FSRM events BEGIN --><Select Path="System">*[System[Provider[@Name='DataScrn']]]</Select><Select Path="System">*[System[Provider[@Name='Quota']]]</Select><Select Path="Application">*[System[Provider[@Name='SrmSvc']]]</Select><Select Path="Application">*[System[Provider[@Name='SrmReports']]]</Select><!-- FSRM events END --><!-- DFS Namespaces events BEGIN --><Select Path="System">*[System[Provider[@Name='Microsoft-Windows-DfsSvc']]]</Select><!-- DFS Namespaces events END --><!-- DFS Replication events BEGIN --><Select Path="DFS Replication">*[System[Provider[@Name='DFS Replication']]]</Select><Select Path="DFS Replication">*[System[Provider[@Name='DFSR']]]</Select><!-- DFS Replication events END --><!-- NTFRS events BEGIN --><Select Path="File Replication Service">*[System[Provider[@Name='File Replication Service']]]</Select><Select Path="File Replication Service">*[System[Provider[@Name='NtFrs']]]</Select><!-- NTFRS events END --><!-- NFS events BEGIN --><Select Path="System">*[System[Provider[@Name='NfsSvr']]]</Select><Select Path="System">*[System[Provider[@Name='Portmap']]]</Select><Select Path="Application">*[System[Provider[@Name='NfsSvc']]]</Select><!-- NFS events END --><!-- SIS events BEGIN --><Select Path="System">*[System[Provider[@Name='SIS']]]</Select><Select Path="Application">*[System[Provider[@Name='Groveler']]]</Select><!-- SIS events END --><!-- Content Indexing events BEGIN --><Select Path="Application">*[System[Provider[@Name='Ci']]]</Select><!-- Content Indexing events END --><!-- Windows Search events BEGIN --><Select Path="Application">*[System[Provider[@Name='Microsoft-Windows-Search']]]</Select><Select Path="Application">*[System[Provider[@Name='Microsoft-Windows-Search-ProfileNotify']]]</Select><!-- Windows Search events END --><!-- FS Role optional components END --><!-- Core components important for FS Role BEGIN --><!-- VDS, VolMgr events BEGIN --><Select Path="System">*[System[Provider[@Name='partmgr']]]</Select><Select Path="System">*[System[Provider[@Name='volmgr']]]</Select><Select Path="System">*[System[Provider[@Name='Virtual Disk Service']]]</Select><Select Path="System">*[System[Provider[@Name='VDS Basic Provider 1.0']]]</Select><Select Path="System">*[System[Provider[@Name='VDS Dynamic Provider 2.0']]]</Select><!-- VDS, VolMgr events END --><!-- VSS, VolSnap events BEGIN --><Select Path="System">*[System[Provider[@Name='Volsnap']]]</Select><Select Path="Application">*[System[Provider[@Name='VSS']]]</Select><!-- VSS, VolSnap events END --><!-- NTFS, TxF, UDF, FAT, exFAT events BEGIN --><Select Path="System">*[System[Provider[@Name='Ntfs']]]</Select><!-- NTFS, TxF, UDF, FAT, exFAT events END --><!-- SMB events BEGIN --><Select Path="System">*[System[Provider[@Name='mrxsmb']]]</Select><Select Path="System">*[System[Provider[@Name='Srv']]]</Select><Select Path="System">*[System[Provider[@Name='Srv2']]]</Select><Select Path="System">*[System[Provider[@Name='Workstation']]]</Select><Select Path="System">*[System[Provider[@Name='Server']]]</Select><!-- SMB events END --><!-- Defrag events BEGIN --><Select Path="Application">*[System[Provider[@Name='Microsoft-Windows-Defrag']]]</Select><!-- Defrag events END --><!-- CHKDSK events BEGIN --><Select Path="Application">*[System[Provider[@Name='Chkdsk']]]</Select><!-- CHKDSK events END --><!-- Core components important for FS Role END --></Query></QueryList></QueryNode></QueryConfig></ViewerConfig></Property>
Since we are only using the name and if it is installed, we do not need to export the entirety of the objects to XML to parse it. A simple workaround is to just Select Name,Installed
as a part of the Get-WindowsFeature
to limit the unused input.
Affected Puppet, Ruby, OS and module versions/distributions
How to reproduce (e.g Puppet code you use)
windowsfeature { 'Backup-Features': ensure => present, installsubfeatures => true, }
OR
windowsfeature { 'Backup-Tools': ensure => present, }
What are you seeing
The error I receive is
Error: Failed to apply catalog: malformed XML: missing tag start Line: 4894 Position: 197033 Last 80 unconsumed characters: < /Property>3 <Property Name="Depends
O
I suppose the error is related just to the features shown. I also use the module to install the SNMP feature and the Telnet client feature without problems.
What behaviour did you expect instead
Output log
Debug: Prefetching default resources for windowsfeature Debug: Executing: 'C:\Windows\system32\WindowsPowershell\v1.0\powershell.exe Imp ort-Module ServerManager; Get-WindowsFeature | ConvertTo-XML -As String -Depth 4 -NoTypeInformation' Debug: Storing state Debug: Stored state in 0.31 seconds Error: Failed to apply catalog: malformed XML: missing tag start Line: 4894 Position: 197033 Last 80 unconsumed characters: < /Property>3 <Property Name="Depends
O
Debug: Dynamically-bound server lookup failed, falling back to report_server set
ting
Debug: Dynamically-bound port lookup failed; falling back to report_port setting
Any additional information you'd like to impart