This message was deleted.
# forge-modules
s
This message was deleted.
d
@Rob Sterenborg sorry we've been utterly buried by customer engagements did you get to the bottom of this?
r
@David Sandilands No, I didn't get any further. I guess it is fair to say that the new DSC is quite new, and I simply couldn't find any relevant information for fixing the issues I'm experiencing. Because the responses that I received eventually dried up, it felt like DSC is somewhat in an early stage with not much relevant documentation (it is all auto-generated, and not really specific for the module) and experienced people to share knowledge. Since I cannot afford to spend weeks on this without getting any positive result, at the moment migrating to the new DSC has been set to a low priority, to be revisited at a later stage. However, if there is any further information about what I can do to make this work, then that would really be much appreciated, and I'd be willing to work on this again.
d
Hi @Rob Sterenborg I asked further sources internally and appreciate you don't want to spend a lot of time on this but had a suggestion that setting https://forge.puppet.com/modules/dsc/xpsdesiredstateconfiguration/reference#validation_mode to resource may fix the situation another module is better documented on using the parameter https://forge.puppet.com/modules/dsc/xwebadministration#validation-mode Let me know if that helps.
r
Hi @David Sandilands. I already tried that parameter, but it didn't resolve the issue. I accept that I must be doing something wrong, but I've been looking everywhere where I could find relevant information, watched a couple of videos on YT with Michael Lombardi (he too mentions the
validation_mode
parameter, which is why I tried it) to get an idea of how things work, and I don't see it. It bugs me that I can't even get something as -seemingly- simple like
dsc_xwindowspackagecab
to work.
d
I hear you @Rob Sterenborg, I personally don't have the windows knowledge to debug this appropriately but if its appearing the documentation is lacking and its possible to trip over in core functionality we need to improve that, let me see where i can escalate internally.
So one more option for the day. Does this make sense or is it off? "So I don't have access to the cab file and I would need to figure out where to get it to do this test. I feel like the get request is assuming the system is internet-connected and is not but that is just my assumption."
r
Hi. The hosts to be provisioned are not internet connected. To mitigate that problem, we've set up local repositories, and for this case we have Puppet code in place to download the installer CAB file on the host first. The downloading part works fine, and the installer CAB is in
C:\Temp
, where the code expects it to be. No internet access is required when I install the package by hand (this is the reason for the package existence). It also installs fine using the old, deprecated DSC. However, when using
dsc_xwindowspackagecab
, it keeps wanting to reinstall/change the package "corrective". To recap... Puppet code:
Copy code
dsc_xwindowspackagecab {'NET-Framework-Core': 
 dsc_ensure => 'Present', 
 dsc_sourcepath => 'C:\Temp', 
 dsc_name => 'microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.cab', 
 dsc_logpath => 'C:\Temp\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.log', 
}
This does in fact install the CAB:
Copy code
PS C:\temp> Get-WindowsFeature -Name NET-Framework-Core

Display Name                                            Name                       Install State
------------                                            ----                       -------------
    [X] .NET Framework 3.5 (includes .NET 2.0 and 3.0)  NET-Framework-Core             Installed
Running the code multiple times results in:
Copy code
Notice: /Stage[pre2]/Platform::Pre::Windows_features_role/Dsc_xwindowspackagecab[NET-Framework-Core]/dsc_logpath: dsc_logpath changed  to 'C:\Temp\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.log' (corrective)

Notice: /Stage[pre2]/Platform::Pre::Windows_features_role/Dsc_xwindowspackagecab[NET-Framework-Core]/dsc_ensure: dsc_ensure changed 'Absent' to 'Present' (corrective)

Notice: dsc_xwindowspackagecab[{:name=>"NET-Framework-Core", :dsc_name=>"microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.cab"}]: Creating: Finished in 9.63 seconds
AFAICS I'm using the latest
dsc-xpsdesiredstateconfiguration
. From `metadata.json`:
Copy code
{
    "name":  "dsc-xpsdesiredstateconfiguration",
    "version":  "9.1.0-0-3",
As mentioned in the top post, I'm experiencing a similar issue when I deploy an IIS website using `dsc_xwebsite`: it keeps wanting to correct (or: "correct"?) the websites it creates, even though the configuration should already be correct when I check this using the GUI.
@David Sandilands I'm really sorry to bother you yet again, but you seem to be the only one responding. So... Is there any news on this? If no news is to be expected, then that's fine too; I mean, I do realize that this is a free forum, not paid support. I would just like to know what to expect; I was just hoping to get some hints here to make the new DSC module behave...
d
@Rob Sterenborg apologies I've been off between covid and annual leave. When I get bits of time I am prodding and asking because I don't like things silently broken. Plenty of people may have tried and given up as it doesn't work.
@Rob Sterenborg Just to share the last update I got internally Going to do a quick test but I think the response from the following is not accurate.
Copy code
$InvokeParams = @{
 Name = 'xWindowsPackageCab';
 Method = 'get';
 Property = @{
 ensure = 'Present';
 sourcepath = 'C:\Temp';
 name = 'microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.cab'
 };
 ModuleName = @{
 ModuleName = 'C:/ProgramData/PuppetLabs/puppet/cache/lib/puppet_x/xpsdesiredstateconfiguration/dsc_resources/xPSDesiredStateConfiguration/xPSDesiredStateConfiguration.psd1';
 RequiredVersion = '9.1.0'
 }
}
That info will be returned based on the following. The
Online = $true
seems wrong to me but I could be wrong.
Copy code
$getWindowsPackageParams = @{
        PackageName = $Name
        Online = $true
    }
and
Copy code
try
    {
        $windowsPackageInfo = Dism\Get-WindowsPackage @getWindowsPackageParams
    }
    catch
    {
        $windowsPackageInfo = $null
    }
So I don't have access to the cab file and I would need to figure out where to get it to do this test. I feel like the get request is assuming the system is internet-connected and is not but that is just my assumption. (edited)
I don't think thats right because online in the MS documents is about "Specifies that the action is to be taken on the operating system that is currently running on the local computer." https://docs.microsoft.com/en-us/powershell/module/dism/get-windowspackage?view=windowsserver2022-ps
r
@David Sandilands No, the hosts are not internet connected. This is why we first download the correct CAB file using the archive module, and then (try to) do a local install. The CAB file can normally be found in the ISO from where Windows is installed in <drive>:\sources\sxs (you must use the same version), but it seems to be up for download on one of MS website: https://dotnetbinaries.blob.core.windows.net/dockerassets/microsoft-windows-netfx3-ltsc2019.zip This archive only contains the CAB file I mentioned.
d
Hi @Rob Sterenborg sorry I think I have an idea but forgive me if this is too obvious or just shows my lack of windows experience but the dsc_name is this correct that it is the same as the CAB name? Would it not be NET-Framework-Core ?
Copy code
dsc_xwindowspackagecab {'NET-Framework-Core': 
 dsc_ensure => 'Present', 
 dsc_sourcepath => 'C:\Temp', 
 dsc_name => 'microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.cab', 
 dsc_logpath => 'C:\Temp\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.log', 
}
r
Hi @David Sandilands I checked the
dsc_xwindowspackagecab
type file, and the comments say:
Copy code
dsc_sourcepath: {
      type: 'String',
      desc: 'The path to the cab file to install or uninstall the package from.',
[...]
    dsc_name: {
      type: 'String',
      desc: 'The name of the package to install or uninstall.',
Maybe it's me being a non-native English speaker, but is
dsc_sourcepath
the path (!) to the file, or is it the complete path + filename? Reading it again,
dsc_name
is most likely supposed to be the same as the resource title, and if so, then
dsc_sourcepath
is most likely the complete path + filename. Anyway, I don't recall exactly what I tried, but I have been trying various combinations. I now changed the code like this:
Copy code
dsc_xwindowspackagecab {'NET-Framework-Core': 
  dsc_ensure => 'Present', 
  dsc_name => 'NET-Framework-Core', 
  dsc_sourcepath => 'C:\Temp\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.cab', 
  dsc_logpath => 'C:\Temp\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.log', 
}
Then I removed the Net-Framework-Core feature, rebooted, and ran the Puppet Agent 2 times in succession, but with the 2nd (and 3rd) run I keep having the issue that the feature is installed, again, corrective:
Copy code
Info: Applying configuration version '1656938822'
Notice: /Stage[pre2]/Platform::Pre::Windows_features_role/Dsc_xwindowspackagecab[NET-Framework-Core]/dsc_logpath: dsc_logpath changed  to 'C:\Temp\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.log' (corrective)
Notice: /Stage[pre2]/Platform::Pre::Windows_features_role/Dsc_xwindowspackagecab[NET-Framework-Core]/dsc_ensure: dsc_ensure changed 'Absent' to 'Present' (corrective)
Notice: dsc_xwindowspackagecab[{:name=>"NET-Framework-Core", :dsc_name=>"microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.cab"}]: Creating: Finished in 9.81 seconds
d
Can you run Dism\Get-WindowsPackage NET-Framework-Core --online This is the code below and other than thinking is that the correct way to pass the online variable, or is the name not matching im not sure how this would be seeing it as absent
Copy code
$getWindowsPackageParams = @{
        PackageName = $Name
        Online = $true
    }



try
    {
        $windowsPackageInfo = Dism\Get-WindowsPackage @getWindowsPackageParams
    }
    catch
    {
        $windowsPackageInfo = $null
    }

    if ($null -eq $windowsPackageInfo -or -not ($windowsPackageInfo.PackageState -in @( 'Installed', 'InstallPending' )))
    {
        $windowsPackageCab.Ensure = 'Absent'
    }
r
That command failed for me, as in it didn't accept parameters. I checked this: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/deploy-net-frame[…]oyment-image-servicing-and-management--dism?view=windows-11, and what does work is:
Copy code
PS C:\Windows\system32> dism /online /Get-FeatureInfo /FeatureName:NetFx3

Deployment Image Servicing and Management tool
Version: 10.0.17763.1697

Image Version: 10.0.17763.3046

Feature Information:

Feature Name : NetFx3
Display Name : .NET Framework 3.5 (includes .NET 2.0 and 3.0)
Description : .NET Framework 3.5 (includes .NET 2.0 and 3.0)
Restart Required : Possible
State : Enabled

Custom Properties:

FWLink : http://go.microsoft.com/fwlink/?LinkId=296822
ServerComponent\Description : .NET Framework 3.5 combines the power of the .NET Framework 2.0 APIs with new technologies for building applications that offer appealing user interfaces, protect your customers' personal identity information, enable seamless and secure communication, and provide the ability to model a range of business processes.
ServerComponent\DisplayName : .NET Framework 3.5 (includes .NET 2.0 and 3.0)
ServerComponent\Id : 220
ServerComponent\InstallWithParentByDefault : true
ServerComponent\Parent : NET-Framework-Features
ServerComponent\Type : Feature
ServerComponent\UniqueName : NET-Framework-Core
ServerComponent\Deploys\Update\Name : NetFx3
ServerComponent\Version\Major : 3
ServerComponent\Version\Minor : 5

The operation completed successfully.
Here I noticed that
Net-Framework-Core
is also known as
NetFx3
, so I changed the package resource title and
dsc_name
to
NetFx3
and ran Puppet Agent again, but after 2+ Puppet Agent runs I still have the same result:
Copy code
Info: Applying configuration version '1656945944'
Notice: /Stage[pre2]/Platform::Pre::Windows_features_role/Dsc_xwindowspackagecab[NetFx3]/dsc_logpath: dsc_logpath changed  to 'C:\Temp\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.log' (corrective)
Notice: /Stage[pre2]/Platform::Pre::Windows_features_role/Dsc_xwindowspackagecab[NetFx3]/dsc_ensure: dsc_ensure changed 'Absent' to 'Present' (corrective)
Notice: dsc_xwindowspackagecab[{:name=>"NetFx3", :dsc_name=>"microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.cab"}]: Creating: Finished in 9.78 seconds
d
I realise I had put two -- for online which is wrong and why that command failed but if you could run
Get-WindowsPackage -Packagename NetFx3 -online
If that fails with
Get-WindowsPackage: The specified package is not valid Windows package.
We know we have the wrong package name. We can get all the packages by running
Get-WindowsPackage -online
and discover what the Packagename is to be present it must match the PackageName Exactly and have a PackageState of installed
Basically this Get-WindowsPackage command is what the puppet provider is using to check, it also just throws any errors or output to being null, which is annoying it would be better if it had them as possible debug output
r
Yes, I corrected the -- when I tried it.
Copy code
PS C:\Windows\system32> Get-WindowsPackage -Packagename NetFx3 -online
Get-WindowsPackage : The parameter is incorrect.
At line:1 char:1
+ Get-WindowsPackage -Packagename NetFx3 -online
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-WindowsPackage], PSArgumentException
    + FullyQualifiedErrorId : Microsoft.Dism.Commands.GetWindowsPackageCommand
Copy code
PS C:\Windows\system32> Get-WindowsPackage -online


[...]

PackageName  : Microsoft-Windows-NetFx3-OnDemand-Package~31bf3856ad364e35~amd64~~10.0.17763.1
PackageState : Installed
ReleaseType  : OnDemandPack
InstallTime  : 7/4/2022 12:44:00 PM

[...]
d
Interesting does it work with the puppet resource dsc_name set to
Copy code
Microsoft-Windows-NetFx3-OnDemand-Package~31bf3856ad364e35~amd64~~10.0.17763.1
ah now this is interesting that error message is a total mess if it gets a packagename doesn't exist it fails
Copy code
Get-WindowsPackage -Packagename fakeymcfakefacepackage -online
Get-WindowsPackage: The parameter is incorrect.
Copy code
 david on Monday at 4:57 PM                                                       0.45s    CPU: 74%  RAM: 12/16GB
  {  home }  Get-WindowsPackage -Packagename Package_for_ServicingStack_702~31bf3856ad364e35~amd64~~22000.702.1.1 -online

PackageName              : Package_for_ServicingStack_702~31bf3856ad364e35~amd64~~22000.702.1.1
Applicable               : True
Copyright                : Microsoft Corporation
Company                  : Microsoft Corporation
CreationTime             : 10/02/1601 21:24:00
Description              : Fix for ServicingStack 10.0.22000.702
InstallClient            : UpdateAgentLCU
InstallPackageName       : Package_for_ServicingStack_702~31bf3856ad364e35~amd64~~22000.702.1.1.mum
InstallTime              : 18/06/2022 02:12:42
LastUpdateTime           : 10/02/1601 21:24:00
DisplayName              : Servicing Stack 10.0.22000.702
ProductName              : Package_for_ServicingStack_702
ProductVersion           :
ReleaseType              : Update
RestartRequired          : Possible
SupportInformation       :
PackageState             : Installed
CompletelyOfflineCapable : No
SelfServicingPackage     : True
CapabilityId             :
Custom Properties        :

Features                 : {}
r
I tried using
Microsoft-Windows-NetFx3-OnDemand-Package~31bf3856ad364e35~amd64~~10.0.17763.1
,
Microsoft-Windows-NetFx3-OnDemand-Package~31bf3856ad364e35~amd64~~10.0.17763.1.mum
and
Microsoft-Windows-NetFx3-OnDemand-Package
, and ran Puppet Agent twice with each, but Puppet keeps reinstalling the feature package.
So I'm one step further. I had no more confidence in the test server I'd been working with, and redeployed it so I could start from scratch. Right now, when I'm executing this piece of code:
Copy code
dsc_xwindowspackagecab { 'Microsoft-Windows-NetFx3-OnDemand-Package~31bf3856ad364e35~amd64~~10.0.17763.1':
  dsc_ensure     => 'Present',
  dsc_name       => 'Microsoft-Windows-NetFx3-OnDemand-Package~31bf3856ad364e35~amd64~~10.0.17763.1',
  dsc_sourcepath => 'C:\Temp\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.cab',
  dsc_logpath    => 'C:\Temp\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.log',
}
It results in:
Copy code
Notice: /Stage[pre2]/Platform::Pre::Windows_features_role/Dsc_xwindowspackagecab[Microsoft-Windows-NetFx3-OnDemand-Package~31bf3856ad364e35~amd64~~10.0.17763.1]/dsc_logpath: dsc_logpath changed  to 'C:\Temp\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.log' (corrective)
Notice: dsc_xwindowspackagecab[{:name=>"Microsoft-Windows-NetFx3-OnDemand-Package~31bf3856ad364e35~amd64~~10.0.17763.1", :dsc_name=>"Microsoft-Windows-NetFx3-OnDemand-Package~31bf3856ad364e35~amd64~~10.0.17763.1"}]: Updating: Finished in 16.28 seconds
Puppet now only keeps correcting an empty
dsc_logfile
value, and no longer changes
dsc_ensure
from
absent
to
present
. So at least this makes it clear that the
dsc_name
should be what
Get-WindowsPackage
returns as
PackageName
, so you have to know that upfront.
Copy code
(Get-WindowsPackage -online -PackageName '*NetFx3*').PackageName
Microsoft-Windows-NetFx3-OnDemand-Package~31bf3856ad364e35~amd64~~10.0.17763.1
The
dsc_xwindowspackagecab
resource
title
seems to be irrelevant; when I set it to something else, the outcome doesn't change. Now I'm hoping that the
dsc_logpath
change can also be made to go away... https://docs.microsoft.com/en-us/powershell/dsc/reference/resources/windows/windowspackagecabresource?view=dsc-1.1 This MS doc says that:
Copy code
LogPath 	Indicates the full path where you want the provider to save a log file to install or uninstall the package.
Which I think I'm doing correctly. The logfile is created and is appended to.
d
So one thing to do would be to see what it thinks the log path was in the catalog it made On the server you can view
%PROGRAMDATA%\PuppetLabs\puppet\cache\catalog\servername.json
(usually
C:\Program Data\PuppetLabs\puppet\cache\catalog\servername.json
). and if you can open that file in vscode or anything with extensions to allow for viewing of json, i think powershell has convertfrom-json, you can see the resource What im wondering is, has puppet done any translation of the log variable you have passed like something with ~~ it thinks its different to the last catalog so it would be useful to look at that source
r
Yeah, I could have shown that already... The section looks like this:
Copy code
{
			"type": "Dsc_xwindowspackagecab",
			"title": ".NET Framework 3.5",
			"tags": [
				"dsc_xwindowspackagecab",
				"class",
				"platform::pre::windows_features_role",
				"platform",
				"pre",
				"windows_features_role",
				"platform::pre2",
				"pre2"
			],
			"file": "/path/to/modules/platform/manifests/pre/windows_features_role.pp",
			"line": 58,
			"exported": false,
			"kind": "compilable_type",
			"parameters": {
				"dsc_ensure": "Present",
				"dsc_sourcepath": "C:\\Temp\\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.cab",
				"dsc_name": "Microsoft-Windows-NetFx3-OnDemand-Package~31bf3856ad364e35~amd64~~10.0.17763.1",
				"dsc_logpath": "C:\\Temp\\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.log"
			}
		},
I don't see any unexpected translation here and I'd say that
dsc_logpath
is already correct. I tested what happens when I replace
~
with
-
, but that didn't help. What I'm unsure of, is that the paths we enter use forward slashes (less hassle with escaping, special chars, etc, and most Puppet modules expect forward slashes too). However
dsc_xwindowspackagecab
doesn't work with forward slashes: it fails when either
dsc_sourcepath
or
dsc_logpath
contain forward slashes. Therefore, before executing
dsc_xwindowspackagecab
, I'm using extra variables to translate all forward slashes in the path into a double backslash; I seem to be unable to translate them into a single backslash. (Maybe this can be done, but in that case I don't know how to do this.) I don't know if the resource actually needs a single backslash, but then again, the CAB file is installed, and the log file is created and appended to in the correct directory, so I would expect it's fine.
d
Could you try the puppet resource with the log path with the extra \ as it appears in the catalog so it would be
Copy code
dsc_logpath    => 'C:\\Temp\\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.log'
I'm not sure why the catalog has picked up an extra \
r
it would be a bit hard to do in the actual Puppet code that I built, because all of the configuration data comes from hiera and is looped for everything that needs to be installed. The data is concatenated inside the loop, and at that point the forward slashes are translated to double backslashes for use with the DSC resources. BTW, when I "notify"
$dsc_logpath
for debugging output, it only shows a single backslash, and that also happens when I dump the variable to a text file. Which at least to me is quite confusing: if there is a double backslash inside the string, I would expect them both to be displayed so I know that everything is fine. The content of the catalog seems to agree with me. However, back on topic... I applied the following using `puppet apply`:
Copy code
dsc_xwindowspackagecab {'NET-Framework-Core': 
  dsc_ensure     => 'Present',
  dsc_name       => 'Microsoft-Windows-NetFx3-OnDemand-Package~31bf3856ad364e35~amd64~~10.0.17763.1',
  dsc_sourcepath => 'C:\\Temp\\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.cab',
  dsc_logpath    => 'C:\\Temp\\microsoft-windows-netfx3-ondemand-package-31bf3856ad364e35-amd64--.log',
}
This results in:
Copy code
PS C:\temp> puppet apply .\t2.pp
Notice: Compiled catalog for <testhost1> in environment puppetwindows_rst_dsc_new in 0.38 seconds
Notice: /Stage[main]/Main/Dsc_xwindowspackagecab[NET-Framework-Core]/dsc_logpath: dsc_logpath changed  to 'C:\Temp\microsoft-windows-netfx3-ondemand-package-31bf3856ad364e35-amd64--.log'
Notice: dsc_xwindowspackagecab[{:name=>"NET-Framework-Core", :dsc_name=>"Microsoft-Windows-NetFx3-OnDemand-Package~31bf3856ad364e35~amd64~~10.0.17763.1"}]: Updating: Finished in 13.63 seconds
Notice: Applied catalog in 14.95 seconds
PS C:\temp>
PS C:\temp>
PS C:\temp>
PS C:\temp> puppet apply .\t2.pp
Notice: Compiled catalog for <testhost1> in environment puppetwindows_rst_dsc_new in 0.16 seconds
Notice: /Stage[main]/Main/Dsc_xwindowspackagecab[NET-Framework-Core]/dsc_logpath: dsc_logpath changed  to 'C:\Temp\microsoft-windows-netfx3-ondemand-package-31bf3856ad364e35-amd64--.log'
Notice: dsc_xwindowspackagecab[{:name=>"NET-Framework-Core", :dsc_name=>"Microsoft-Windows-NetFx3-OnDemand-Package~31bf3856ad364e35~amd64~~10.0.17763.1"}]: Updating: Finished in 9.40 seconds
Notice: Applied catalog in 10.84 seconds
The calalog (still) shows:
Copy code
{
			"type": "Dsc_xwindowspackagecab",
			"title": ".NET Framework 3.5",
			"tags": [
				"dsc_xwindowspackagecab",
				"class",
				"platform::pre::windows_features_role",
				"platform",
				"pre",
				"windows_features_role",
				"platform::pre2",
				"pre2"
			],
			"file": "/etc/puppetlabs/code/environments/puppetwindows_rst_dsc_new/modules/platform/manifests/pre/windows_features_role.pp",
			"line": 55,
			"exported": false,
			"kind": "compilable_type",
			"parameters": {
				"dsc_ensure": "Present",
				"dsc_sourcepath": "C:\\Temp\\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.cab",
				"dsc_name": "Microsoft-Windows-NetFx3-OnDemand-Package~31bf3856ad364e35~amd64~~10.0.17763.1",
				"dsc_logpath": "C:\\Temp\\microsoft-windows-netfx3-ondemand-package-31bf3856ad364e35-amd64--.log"
			}
		},
So the
dsc_xwindowspackagecab
resource wants to change the
dsc_logpath
from having double backslashes to having single backslashes, even though that's not what the code says, and it also doesn't end up in the catalog. If you really need me to test this in the actual Puppet code, then I'll need more time to make that happen.
d
If you could it would be great but I'm asking the module team if they have experienced this before to see if there is a better way to deal with this. I'm also asking how we update the readme for the module so the package name attribute is a lot clearer for CAB files
So the general advice/testing seems to be around making sure all paths are given with // as per the tip in the likes of https://puppet.com/docs/puppet/7/lang_data_string.html#lang_data_string_single_quoted_strings-escape-sequences Updating the readmes is harder than I hoped due to the way these modules are automatically generated but their are improvements due to the UX soon
r
You are typing:
//
, but I think that's a typo, because The documentation you're pointing me to says to use:
\\
Judging by my code, I'm using
\\
with DSC resources. At least the catalog says that I do. (Or is it doing some magic on its own?) (So far all other resources are fine with the values/strings that I'm feeding them, so for this discussion I'd like to focus on DSC.) The whole backslash thing is confusing me. Not in using them (I know how and when to use them), but while handling/manipulating strings containing them. For example:
Copy code
$a = 'C:/Temp/installer.cab'

$b = regsubst($a, '/', '\\', 'G')
$c = regsubst($a, '/', '\\\\', 'G')

notice "[a] ${a}"
notice "[b] ${b}"
notice "[c] ${c}"

file { '/tmp/t1.txt':
  content => "[a] ${a}\n[b] ${b}\n[c] ${c}\n\n",
}
Executing this code:
Copy code
[r.sterenborg@ntt-ws-rst2 puppet]$ puppet apply t1.pp 
Notice: Scope(Class[main]): [a] C:/Temp/installer.cab
Notice: Scope(Class[main]): [b] C:\Temp\installer.cab
Notice: Scope(Class[main]): [c] C:\Temp\installer.cab
Notice: Compiled catalog for ntt-ws-rst2.netmatch.local in environment production in 0.01 seconds
Notice: /Stage[main]/Main/File[/tmp/t1.txt]/ensure: defined content as '{md5}d0b0f45810326fe1f2691c07f5d4e27d'
Notice: Applied catalog in 0.09 seconds

[r.sterenborg@ntt-ws-rst2 puppet]$ cat /tmp/t1.txt 
[a] C:/Temp/installer.cab
[b] C:\Temp\installer.cab
[c] C:\Temp\installer.cab
Variables
$b
and
$c
are showing identical string values. I expected to see
[b] "C:\\Temp\\installer.cab"
and
[c] "C:\\\\Temp\\\\installer.cab"
, but
notice
is showing something else, and so does output file
t1.txt
. And if
\\
is silently translated to
\
, then shouldn't
\\\\
have been translated to
\\
? I hard-coded the path at your request using double backslashes. The actual code now reads:
Copy code
dsc_xwindowspackagecab { '.NET Framework 3.5':
            dsc_ensure     => 'Present',
            dsc_name       => 'Microsoft-Windows-NetFx3-OnDemand-Package~31bf3856ad364e35~amd64~~10.0.17763.1',
            dsc_sourcepath => 'C:\\Temp\\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.cab',
            dsc_logpath    => 'C:\\Temp\\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.log',
          }
So, no string replacements, just as shown in the above snippet. But it's not changing anything (see below). Having done all this... The fact remains that the CAB file does get installed if it is not installed already. That means that the strings supplied to the
dsc_sorucepath
and
dsc_logpath
parameters of the
dsc_xwindowspackagecab
resource are fine. If they were not, the CAB file wouldn't install, because either the resource cannot find the CAB file, the logfile would not be created which might have generated an error (from all of my testing I conclude that an error is most likely to occur), or the resource cannot handle the path separator type, resulting in an error. However, instead the
dsc_xwindowspackagecab
resource says:
Copy code
Notice: /Stage[pre2]/Platform::Pre::Windows_features_role/Dsc_xwindowspackagecab[.NET Framework 3.5]/dsc_logpath: dsc_logpath changed  to 'C:\Temp\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.log' (corrective)
To me this indicates that there isn't any path problem or problem pertaining to slashes or backslashes, or at least there shouldn't be. As far as I can conclude, the resource just doesn't "see" that
dsc_logpath
already has a value configured, making it want to replace an empty string with a string containing a path. Also, the path in the replacement string is not the same as what the catalog says. That seems fine because in Windows a single backslash is the native path separator, but if the path is compared to what is in the catalog, then it will never match because of a mismatch in the number of backslashes (unless some voodoo happens before comparing).
d
Sorry I hate the slash thing 🤦🏻 I have muddled there and thinknig about it more it being a corrective change indicates the catalog hasn't changed so I'm miles off. Will have a think about why it wouldn't be getting it