You are typing: `//`, but I think that's a typo, b...
# forge-modules
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).