I wonder if it's possible in puppet (windows agent) for a variable to hold the value of a file name, then add this variable value to an exec windows cmd.exe command? i.e. I'm trying to copy a file from a shared drive to c:\temp like this:
$setup_msi = "myprogram.msi"
exec { 'copy_MSI_c:\temp':
command => 'C:\\windows\system32\cmd.exe /c "copy i:\\data\\${setup_msi}" c:\\temp'
}
But when the windows puppet agent runs, puppet parses the $setup_msi variable name itself and not the value that said variable contains. I was hoping it would parse it like this: C:\windows\system32\cmd.exe /c "copy i:\data\myprogram.msi c:\temp"
Any help would be greattly appreciated.
Thanks.
Fr3edom21.
The command string is containted within single quote marks and this is why the variable is not substitiuted.
Your code should be
$setup_msi = "myprogram.msi"
exec { 'copy_MSI_c:\temp':
command => "C:\\windows\system32\cmd.exe /c \"copy i:\\data\\${setup_msi} c:\\temp\""
}
Since usage of double quotation marks means that the string itself is going to be parsed by puppet, it is also necessary to escape any double quotes within that string, thus \"copy instead of "copy.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With